[R] survfit function - event information???

David Winsemius dwinsemius at comcast.net
Tue Jun 22 01:19:55 CEST 2010


On Jun 21, 2010, at 6:50 PM, CC wrote:

> Hi all!
>
> I am trying to extract output information from the survfit function  
> in order
> to generate a matrix of select output for multiple factors.
> Specifically, I am interested in extracting the number of events (in  
> the
> output below: 106, 2, 3).  The variable names represented in my  
> function
> (ee) are shown below, but none of those variables correspond to the  
> column
> of events as shown in the output.
>
> What should I be using to call the number of events?
>
> *******************
>
> *Format of the Matrix:*
>
>             [,1]               [,2]    [,3]    [,4]   [,5]     [6]
> [7]     [8]
> [1,] "rs12082473_T" "2288" "2211" "21"  "56"  (Number of Events)
>
> *******************
> *CODE & Output:*
>
> ee=survfit(Surv(dta$dmi,dta$mi==1)~dta[,i],data=dta)

Couldn't you just sum dta$mi==1 at this point?  Perhaps with  
complete.cases or na.omit surrounding an appropriate subset of  
data.... untested in absence of reproducible example:

sum(dta[!is.na(dta[,i])]$mi==1)

See also:
https://stat.ethz.ch/pipermail/r-help/2010-June/242478.html



>           records n.max n.start *events* median 0.95LCL 0.95UCL
> dta[, i]=0    2211  2211    2211    *106 *    NA      NA      NA
> dta[, i]=1      21    21      21      *2 *    NA      NA      NA
> dta[, i]=2      56    56      56     * 3*     NA      NA      NA
>
> *******************
> *Variable Names*:
>
> names(ee)
> [1] "n"         "time"      "n.risk"    "n.event"   "n.censor"  "surv"
> [7] "type"      "strata"    "std.err"   "upper"     "lower"      
> "conf.type"
> [13] "conf.int"  "na.action" "call"
>
> ****************
>
> Thanks!
> CC


-- 
David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list