Description Details Author(s) See Also Examples
This package generates Kaplan-Meier curves and cumulative incidence plots for competing risks models.
This package was not yet installed at build time.
Index: This package was not yet installed at build time.
This package outputs Kaplan-Meier plots and cumulative incidence plots for competing risks models. A table of the number of observations in the risk set at each specified time point is printed below the plot.
Erica Wozniak
Maintainer: Erica Wozniak <ewozniak@mcw.edu>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | library(survival)
# Set up data as a survival object
# KM plot for time to death
# Censor those who receive a transplant or are indicated by the dataset as censored
pbc_km <- na.omit(pbc[, c("time", "status", "trt")])
pbc_km$status[pbc_km$status == 1] <- 0
pbc_km$status[pbc_km$status == 2] <- 1
pbc_km$SurvObj <- with(pbc_km,
Surv(time = time,
event = status)
)
fit <- survfit(SurvObj ~ trt,
data = pbc_km,
conf.type = "log-log")
# Usage note: if gridlines are extending outside the plot border, run
# "dev.off()" and then run the plotting function again.
# Default options only
km_plot(fit = fit)
# Customized pretty plot with some options
km_plot(fit = fit,
type = "km",
col = c("orange3", "olivedrab"),
# Add an extra major gridline and risk table column at time 4500
xlim_major = c(0, 1000, 2000, 3000, 4000, 4500, 5000),
plot_title = "Primary biliary cirrhosis survival",
plot_subtitle = "By randomized treatment status",
y_axis_label = "Survival",
x_axis_label = "Time since registration (days)",
group_names = c("D-penacillamine", "Placebo"),
risk_table_title = bquote(italic("Patients at risk:")))
# Customized retro plot with lots of options
km_plot(fit = fit,
font_family = "mono",
type = "1-km",
col = c("black", "black"),
lty = c(1, 2),
lwd = c(2, 2),
xlim_major = c(0, 500, 1000, 2000, 3000, 3375, 4000, 4500, 5000),
col_grid_major = "gray80",
col_grid_minor = "gray92",
plot_title = bquote(bold("Death following transplant registration")),
plot_subtitle = "Mayo Clinic 1974-1984",
plot_title_size = 1,
y_axis_label = bquote(bold("Cumulative incidence")),
x_axis_label = bquote(bold("Days")),
group_names = c("D-penacillamine", "Placebo"),
group_order = c(2, 1),
risk_table_title = bquote(bold(underline("RISK TABLE"))),
extra_left_margin = 5)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.