[R] Extracting values from Surv function in survival package

Göran Broström gb @end|ng |rom eh@r@@e
Thu May 16 09:52:37 CEST 2024


Hi Dennis,

look at the help page for summary.survfit, the Value n.event.

Göran

On 2024-05-15 22:41, Dennis Fisher wrote:
> OS X
> R 4.3.3
> 
> Colleagues
> 
> I have created objects using the Surv function in the survival package:
>> FIT.1
> Call: survfit(formula = FORMULA1)
> 
>                                         n events median 0.95LCL 0.95UCL
> SUBDATA$ARM=1, SUBDATA[, EXP.STRAT]=0 18     13    345     156      NA
> SUBDATA$ARM=2, SUBDATA[, EXP.STRAT]=1 13      5     NA     186      NA
> SUBDATA$ARM=2, SUBDATA[, EXP.STRAT]=2  5      5    168      81      NA
> SUBDATA$ARM=2, SUBDATA[, EXP.STRAT]=3  1      1     22      NA      NA
> 
> I am interested in extracting the “n” and “events” values.
> “n” is easy:
>> FIT.1[[1]]
> [1] 18 13  5  1
> 
> or
>> FIT.1$n
> [1] 18 13  5  1
> 
> But I can’t figure out how to access “events”.
> 
> str(FIT.1) provides no insights:
> List of 17
>   $ n        : int [1:4] 18 13 5 1
>   $ time     : num [1:37] 45 106 107 124 152 156 170 176 319 371 ...
>   $ n.risk   : num [1:37] 18 17 16 15 14 13 12 11 10 9 ...
>   $ n.event  : num [1:37] 1 1 1 1 1 1 1 1 1 1 ...
>   $ n.censor : num [1:37] 0 0 0 0 0 0 0 0 0 0 ...
>   $ surv     : num [1:37] 0.944 0.889 0.833 0.778 0.722 ...
>   $ std.err  : num [1:37] 0.0572 0.0833 0.1054 0.126 0.1462 ...
>   $ cumhaz   : num [1:37] 0.0556 0.1144 0.1769 0.2435 0.315 ...
>   $ std.chaz : num [1:37] 0.0556 0.0809 0.1022 0.1221 0.1414 ...
>   $ strata   : Named int [1:4] 18 13 5 1
>    ..- attr(*, "names")= chr [1:4] "SUBDATA$ARM=1, SUBDATA[, EXP.STRAT]=0" "SUBDATA$ARM=2, SUBDATA[, EXP.STRAT]=1" "SUBDATA$ARM=2, SUBDATA[, EXP.STRAT]=2" "SUBDATA$ARM=2, SUBDATA[, EXP.STRAT]=3"
>   $ type     : chr "right"
>   $ logse    : logi TRUE
>   $ conf.int : num 0.95
>   $ conf.type: chr "log"
>   $ lower    : num [1:37] 0.844 0.755 0.678 0.608 0.542 ...
>   $ upper    : num [1:37] 1 1 1 0.996 0.962 ...
>   $ call     : language survfit(formula = FORMULA1)
>   - attr(*, "class")= chr "survfit"
> 
> If I could access:
>                                         n events median 0.95LCL 0.95UCL
> SUBDATA$ARM=1, SUBDATA[, EXP.STRAT]=0 18     13    345     156      NA
> SUBDATA$ARM=2, SUBDATA[, EXP.STRAT]=1 13      5     NA     186      NA
> SUBDATA$ARM=2, SUBDATA[, EXP.STRAT]=2  5      5    168      81      NA
> SUBDATA$ARM=2, SUBDATA[, EXP.STRAT]=3  1      1     22      NA      NA
> it should be easy to get “events”.
> 
> Any thoughts?
> 
> Dennis
> 
> Dennis Fisher MD
> P < (The "P Less Than" Company)
> Phone / Fax: 1-866-PLessThan (1-866-753-7784)
> www.PLessThan.com
> 
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list