[R] What is median in survfit
Thomas Lumley
tlumley at u.washington.edu
Fri Jun 10 17:04:17 CEST 2005
On Fri, 10 Jun 2005, Remigijus Lapinskas wrote:
> Dear All,
>
> A very simple question:
>
> > library(survival)
> > fit <- coxph(Surv(time, status) ~ x, data=aml)
> > survfit(fit)
> Call: survfit.coxph(object = fit)
>
> n events median 0.95LCL 0.95UCL
> 23 18 30 18 45
>
> I believe I know what is median here, but how to extract it?
>
This turns out to be trickier than one would ideally like
fit$time[min(which(fit$surv<=0.5))]
works if there is a single stratum, as in your example.
Or, even uglier, you can capture then entire table with
> read.table(textConnection(capture.output(survfit(fit))),skip=2,header=TRUE)
n events median X0.95LCL X0.95UCL
1 23 18 30 18 45
which does work for stratified survfits.
-thomas
More information about the R-help
mailing list