Skip to content
Prev 274661 / 398506 Next

Extracting results from a function output

Often the summary() methods for the modelling functions
contain the kinds of details you are looking for.  Sometimes
there are special extractor functions but often not.
You have to study the help file for summary.<objectClass>
and the vignettes for the package, and perhaps do a little
experimentation to figure it out.

  > library(survival)
  > fit <- survfit(Surv(time, status) ~ x, data=leukemia)
  > fit
  Call: survfit(formula = Surv(time, status) ~ x, data = leukemia)
  
                  records n.max n.start events median 0.95LCL 0.95UCL
  x=Maintained         11    11      11      7     31      18      NA
  x=Nonmaintained      12    12      12     11     23       8      NA
  > summary(fit)$table[, "median"]
     x=Maintained x=Nonmaintained 
               31              23 
  > summary(fit)$table["x=Maintained", "median"]
  [1] 31


Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com