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 · 2 comments
Closed

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

kassambara opened this issue Apr 16, 2017 · 2 comments

Comments

@kassambara
Copy link
Owner

@kassambara kassambara commented Apr 16, 2017

(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 added a commit that referenced this issue Apr 28, 2017
@kassambara
Copy link
Owner Author

@kassambara kassambara commented Apr 28, 2017

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 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,

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.