Helper function to retrieve median survival time from a survival::survfit
object
Source: R/survival-helper.R
medSurv_makeup.Rd
Extract and display median survival time with confidence interval
Arguments
- km_fit
returned object from
survival::survfit
- legend
a character string, name used in 'type' column in returned data frame
- time_scale
a character string, 'years', 'months', 'weeks' or 'days', time unit of median survival time
Examples
data(adtte_sat)
data(pseudo_ipd_sat)
library(survival)
combined_data <- rbind(adtte_sat[, c("TIME", "EVENT", "ARM")], pseudo_ipd_sat)
kmobj <- survfit(Surv(TIME, EVENT) ~ ARM, combined_data, conf.type = "log-log")
# Derive median survival time
medSurv <- medSurv_makeup(kmobj, legend = "before matching", time_scale = "day")
medSurv
#> treatment type records n.max n.start events rmean se(rmean)
#> 1 A before matching 500 500 500 190 265.1012 10.80981
#> 2 B before matching 300 300 300 178 130.9893 10.24910
#> median 0.95LCL 0.95UCL
#> 1 230.94839 191.10767 313.1574
#> 2 83.58535 68.82298 101.0786