[R] How to access results of survival analysis

Heinz Tuechler tuechler at gmx.at
Sun Feb 6 17:58:12 CET 2005


To sum up:
Starting from the question, how to access the results of survival analysis
Uwe Liggens suggested to ...copy code for calculation of the required
values from those print methods into your own functions...

Since I am new to R I choose the easiest way I knew and changed a few lines
in the print.survfit method. I introduced a parameter "ret.res=FALSE" set
to false to preserve the normal behaviour of print.
The second last line "invisible(x)" I changed to:

if (ret.res)
	invisible(list(x,x1))
else
	invisible(x)

Finally I source the changed function.
Of course this is only a temporary workaround, but it seems to work.

Thanks,
Heinz Tüchler

At 19:09 05.02.2005 +0100, Uwe Ligges wrote:
>Heinz Tuechler wrote:
>
>> At 15:19 05.02.2005 +0100, Uwe Ligges wrote:
>> 
>>>Heinz Tuechler wrote:
>>>
>>>>Hello,
>>>>
>>>>it seems that the main results of survival analysis with package survival
>>>>are shown only as side effects of the print method.
>>>>
>>>>If I compute e.g. a Kaplan-Meier estimate by 
>>>>
>>>>
>>>>>km.survdur<-survfit(s.survdur) 
>>>>
>>>>then I can simply print the results by 
>>>>
>>>>
>>>>>km.survdur
>>>>
>>>>Call: survfit(formula = s.survdur)
>>>>
>>>>      n  events  median 0.95LCL 0.95UCL 
>>>>  100.0    58.0    46.8    41.0    79.3 
>>>>
>>>>Is there a simple method to access these results, e.g. if I want to print
>>>>only the median with the confidence limits?
>> 
>> 
>> ...
>> 
>>>No, the print methods do not return those values.
>>>But you can copy code for calculation of the required values from those 
>>>print methods into your own functions...
>>>
>>>Uwe Ligges
>>>
>>>
>> 
>> Thank you for your answer. I assume, you suggest to use
>> capture.output(print(...)). 
>
>No, I suggested to copy the code from survival:::print.survfit and Co. 
>that calculates the values you are looking for...
>
>Uwe
>
> > Without your response I would have believed
>> that I had missed an important possibility of R.
>> 
>> Regarding the Cox-Model Ales Ziberna gave me a useful hint to use summary()
>> which returns a list.
>> 
>> Thanks to both of you,
>> 
>> Heinz Tüchler
>
>




More information about the R-help mailing list