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

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to