Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plot a list of survfit objects with ggsurvplot() #204

Closed
kassambara opened this issue Apr 28, 2017 · 1 comment
Closed

Plot a list of survfit objects with ggsurvplot() #204

kassambara opened this issue Apr 28, 2017 · 1 comment

Comments

@kassambara
Copy link
Owner

No description provided.

@kassambara
Copy link
Owner Author

The function ggsurvplot() can take a list of survfit objects and produces a list of ggsurvplots.

Simplified formats

ggsurvplot(fit, data, title = NULL,
           legend.labs = NULL, legend.title = "Strata", ...)

Where,

  • fit can be a list of survfit objects
  • data is the data used to fit survival curves. Can be also a list of same length than fit.
  • title is title of the plot. Can be a character vector or a list of titles of same length than fit. If title is not specified and fit is a named list, then the names of fit list are used as title.
  • legend.labs is character vector specifying legend labels. Used to replace the names of the strata from the fit. Should be given in the same order as those strata. Can be a list when fit is a list.
  • legend.title is the legend title for each plot. Can be a character vector or a list of titles of same length than fit.

Compute multiple survival curves

 library(survival)
 # Compute multiple survival curves
 fit1 <- survfit(Surv(time, status) ~ sex, data = colon)
 fit2 <- survfit(Surv(time, status) ~ adhere, data = colon)
 fits <- list(sex = fit1, adhere = fit2)

Visualize

library("survminer")
legend.title <- list("sex", "rx")
ggsurv.list <- ggsurvplot(fits, colon, legend.title = legend.title, 
                           risk.table = TRUE, tables.theme = theme_cleantable(),
                           pval = TRUE, conf.int = TRUE, palette = "jco")
 names(ggsurv.list)
[1] "sex"    "adhere"
 ggsurv.list$sex

rplot10

 ggsurv.list$adhere

rplot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant