View source: R/plot_survival.R
plot_survival | R Documentation |
This function plots one or several survival curves for a given time-to-event model.
plot_survival( fit, fun = NULL, CI = FALSE, censor = TRUE, pal_curves = "npg", title = ifelse(is.null(fit$strata), "Survival Curve", "Survival Curves"), leg.txt = NULL, legend = "right", ... )
fit |
An object of class |
fun |
An arbitrary function defining a transformation of the survival
curve(s). Common transformations can be specified with a character
argument, e.g. |
CI |
Plot confidence intervals? |
censor |
Include tick-marks to indicate censored subjects? |
pal_curves |
String specifying the color palette to use when plotting
multiple vectors. Options include |
title |
Optional plot title. |
leg.txt |
Optional legend title. |
legend |
Legend position. Must be one of |
... |
Additional arguments to be passed to |
Survival curves visualize the fit of a time-to-event model, e.g. a Kaplan-Meier estimator or a Cox proportional hazards regression. They are an essential tool in survival analysis, providing a simple and intuitive visual summary of the relative risk associated with different conditions.
plot_survival
is a lightweight wrapper for the
ggsurvplot
function from the survminer
package,
which offers an impressive array of customization options for plotting
survival curves. plot_survival
alters the default output of
ggsurvplot
to align it with that of other figures generated by
bioplotr
, but you can override those settings and/or take advantage of extra
ggsurvplot
functionalities by passing additional arguments to
plot_survival
.
Andersen, P. & Gill, R. (1982). Cox's regression model for counting processes, a large sample study. Annals of Statistics, 10, 1100-1120.
Cox, D.R. (1972). Regression Models and Life-Tables. J. R. Stat. Soc., Series B, 34(2): 187-220.
Kaplan, E.L. & Meier, P. (1958). Nonparametric estimation from incomplete observations. J. Amer. Stat. Assn., 53(282): 457-481.
library(survival) fit <- survfit(Surv(time, status) ~ sex, data = lung) plot_survival(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.