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

Extract median survival from survfit objects #207

Closed
kassambara opened this issue May 1, 2017 · 1 comment
Closed

Extract median survival from survfit objects #207

kassambara opened this issue May 1, 2017 · 1 comment

Comments

@kassambara
Copy link
Owner

No description provided.

@kassambara
Copy link
Owner Author

New function surv_median() added to easily extract median survivals from one or a list of survfit objects.

# Load required packages
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::
library("survival")
library("survminer")

# compute different survfits
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::
fit.null <- surv_fit(Surv(time, status) ~ 1, data = colon)

fit1 <- surv_fit(Surv(time, status) ~ sex, data = colon)

fit2 <- surv_fit(Surv(time, status) ~ adhere, data = colon)

fit.list <- list(sex = fit1, adhere = fit2)
surv_median(fit.null)
strata median lower upper
1    All   2351  2018  2910
surv_median(fit2)
    strata median lower upper
1 adhere=0   2718  2213    NA
2 adhere=1   1272   997  1885
surv_median(fit.list)
$sex
  strata median lower upper
1  sex=0   2174  1752    NA
2  sex=1   2527  1976  2910

$adhere
    strata median lower upper
1 adhere=0   2718  2213    NA
2 adhere=1   1272   997  1885

surv_median(fit.list, combine = TRUE)
      id   strata median lower upper
1    sex    sex=0   2174  1752    NA
2    sex    sex=1   2527  1976  2910
3 adhere adhere=0   2718  2213    NA
4 adhere adhere=1   1272   997  1885

kassambara added a commit that referenced this issue May 1, 2017
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