This also works:
> library(survMisc)
> fit <- survfit(Surv(time, status) ~ x, data = aml)
> median(fit)
median
x=Maintained 31
x=Nonmaintained 23
And without the names (i.e. remove the structure of a data.frame
):
> unname(unlist(median(fit)))
[1] 31 23
It's nice if you also want the confidence interval (default is 'log'):
> median(fit, CI=TRUE)
median lower upper
x=Maintained 31 13 NA
x=Nonmaintained 23 5 43