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

ggsurvplot(): Option to add 'all' patients' Survival Curves Needed #194

Closed
kassambara opened this issue Apr 16, 2017 · 3 comments
Closed

Comments

@kassambara
Copy link
Owner

(User request by e-mail)

  • Plot survival curves of patients stratified by grouping variables
  • Add on the same plot, the survival curves of 'all' patients.

A simple option to do this is needed.

related issue: #98

@kassambara
Copy link
Owner Author

New option added now in ggsurvplot() to add he survival curves of (all) pooled patients onto the main survival plot stratified by grouping variables.

  • Load required package and fit survival curves:
# Load required packages
library("survival")
library("survminer")

# Fit survival curves
fit <- surv_fit(Surv(time, status) ~ sex, data = lung)
  • Basic survival curves:
# Visualize survival curves
ggsurvplot(fit, data = lung, 
           risk.table = TRUE, pval = TRUE,
           surv.median.line = "hv", palette = "jco")

rplot

  • Add survival curves of pooled patients:

Use add.all = TRUE option

# Add survival curves of pooled patients (Null model)
# Use add.all = TRUE option
ggsurvplot(fit, data = lung, 
           risk.table = TRUE, pval = TRUE,
           surv.median.line = "hv", palette = "jco", 
           add.all = TRUE)

rplot07

@lli1026
Copy link

lli1026 commented May 4, 2020

when i use "add.all=TRUE", got a error message(Error in model.frame.default(formula = surv.object ~ strata.val, data = list( : variable lengths differ (found for 'strata.val')), it works fine without "add.all", any ideas? Thanks,

@DeepblueLam
Copy link

when i use "add.all=TRUE", got a error message(Error in model.frame.default(formula = surv.object ~ strata.val, data = list( : variable lengths differ (found for 'strata.val')), it works fine without "add.all", any ideas? Thanks,

i got the same error. how did you solve this?

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

3 participants