[R] simple save question

David Winsemius dwinsemius at comcast.net
Tue Jul 12 22:38:44 CEST 2011


On Jul 12, 2011, at 2:31 PM, Tom La Bone wrote:

>
> Here is a worked example. Can you point out to me where in temp  
> rmean is
> stored? Thanks.

It is not. You need to read the ?print.survfit page:

Value
x, with the invisible flag set to prevent printing. (The default for  
all print functions in R is to return the object passed to them;  
print.survfit follows the pattern. If you want to capture these  
printed results for further processing, see the table component of  
summary.survfit.)

-- 
David.
>
> Tom
>
>
>> library(survival)
>> library(ISwR)
>>
>> dat.s <- Surv(melanom$days,melanom$status==1)
>> fit <- survfit(dat.s~1)
>> plot(fit)
>> summary(fit)
> Call: survfit(formula = dat.s ~ 1)
>
> time n.risk n.event survival std.err lower 95% CI upper 95% CI
>  185    201       1    0.995 0.00496        0.985        1.000
>  204    200       1    0.990 0.00700        0.976        1.000
>  210    199       1    0.985 0.00855        0.968        1.000
>  232    198       1    0.980 0.00985        0.961        1.000
>  279    196       1    0.975 0.01100        0.954        0.997
>  295    195       1    0.970 0.01202        0.947        0.994
>  386    193       1    0.965 0.01297        0.940        0.991
>  426    192       1    0.960 0.01384        0.933        0.988
>  469    191       1    0.955 0.01465        0.927        0.984
>  529    189       1    0.950 0.01542        0.920        0.981
>  621    188       1    0.945 0.01615        0.914        0.977
>  629    187       1    0.940 0.01683        0.907        0.973
>  659    186       1    0.935 0.01748        0.901        0.970
>  667    185       1    0.930 0.01811        0.895        0.966
>  718    184       1    0.925 0.01870        0.889        0.962
>  752    183       1    0.920 0.01927        0.883        0.958
>  779    182       1    0.915 0.01981        0.877        0.954
>  793    181       1    0.910 0.02034        0.871        0.950
>  817    180       1    0.904 0.02084        0.865        0.946
>  833    178       1    0.899 0.02134        0.859        0.942
>  858    177       1    0.894 0.02181        0.853        0.938
>  869    176       1    0.889 0.02227        0.847        0.934
>  872    175       1    0.884 0.02272        0.841        0.930
>  967    174       1    0.879 0.02315        0.835        0.926
>  977    173       1    0.874 0.02357        0.829        0.921
>  982    172       1    0.869 0.02397        0.823        0.917
> 1041    171       1    0.864 0.02436        0.817        0.913
> 1055    170       1    0.859 0.02474        0.812        0.909
> 1062    169       1    0.854 0.02511        0.806        0.904
> 1075    168       1    0.849 0.02547        0.800        0.900
> 1156    167       1    0.844 0.02582        0.794        0.896
> 1228    166       1    0.838 0.02616        0.789        0.891
> 1252    165       1    0.833 0.02649        0.783        0.887
> 1271    164       1    0.828 0.02681        0.777        0.883
> 1312    163       1    0.823 0.02713        0.772        0.878
> 1435    161       1    0.818 0.02744        0.766        0.874
> 1506    159       1    0.813 0.02774        0.760        0.869
> 1516    155       1    0.808 0.02805        0.755        0.865
> 1548    152       1    0.802 0.02837        0.749        0.860
> 1560    150       1    0.797 0.02868        0.743        0.855
> 1584    148       1    0.792 0.02899        0.737        0.851
> 1621    146       1    0.786 0.02929        0.731        0.846
> 1667    137       1    0.780 0.02963        0.725        0.841
> 1690    134       1    0.775 0.02998        0.718        0.836
> 1726    131       1    0.769 0.03033        0.712        0.831
> 1933    110       1    0.762 0.03085        0.704        0.825
> 2061     95       1    0.754 0.03155        0.694        0.818
> 2062     94       1    0.746 0.03221        0.685        0.812
> 2103     90       1    0.737 0.03290        0.676        0.805
> 2108     88       1    0.729 0.03358        0.666        0.798
> 2256     80       1    0.720 0.03438        0.656        0.791
> 2388     75       1    0.710 0.03523        0.645        0.783
> 2467     69       1    0.700 0.03619        0.633        0.775
> 2565     63       1    0.689 0.03729        0.620        0.766
> 2782     57       1    0.677 0.03854        0.605        0.757
> 3042     52       1    0.664 0.03994        0.590        0.747
> 3338     35       1    0.645 0.04307        0.566        0.735
>>
>> print(fit, print.rmean=TRUE)
> Call: survfit(formula = dat.s ~ 1)
>
>   records      n.max    n.start     events     *rmean *se(rmean)      
> median
>       205        205        205         57       4125         
> 161         NA
>   0.95LCL    0.95UCL
>        NA         NA
>    * restricted mean with upper limit =  5565
>>
>> temp <- summary(fit)
>> str(temp)
> List of 12
> $ surv    : num [1:57] 0.995 0.99 0.985 0.98 0.975 ...
> $ time    : num [1:57] 185 204 210 232 279 295 386 426 469 529 ...
> $ n.risk  : num [1:57] 201 200 199 198 196 195 193 192 191 189 ...
> $ n.event : num [1:57] 1 1 1 1 1 1 1 1 1 1 ...
> $ conf.int: num 0.95
> $ type    : chr "right"
> $ table   : Named num [1:7] 205 205 205 57 NA NA NA
>  ..- attr(*, "names")= chr [1:7] "records" "n.max" "n.start"  
> "events" ...
> $ n.censor: num [1:57] 0 0 0 1 0 0 0 0 0 0 ...
> $ std.err : num [1:57] 0.00496 0.007 0.00855 0.00985 0.011 ...
> $ lower   : num [1:57] 0.985 0.976 0.968 0.961 0.954 ...
> $ upper   : num [1:57] 1 1 1 1 0.997 ...
> $ call    : language survfit(formula = dat.s ~ 1)
> - attr(*, "class")= chr "summary.survfit"
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/simple-save-question-tp3429148p3663170.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list