[Rd] Adding a survival object to a data frame (PR#10510)
Peter Dalgaard
P.Dalgaard at biostat.ku.dk
Wed Dec 12 16:23:15 CET 2007
ripley at stats.ox.ac.uk wrote:
> Your example is not reproducible without 'library(survival)'.
> When I include that, I get
>
>
>> head(D,20)
>>
> stime status surv
> 1 176 TRUE 176
> ...
>
> Objects of class "Surv" are from the contributed package survival, and you
> need that attached to deal with them properly.
>
>
>
... but even if you detach it, you do not get the symptoms shown:
> head(D,5)
stime status surv.time surv.status
1 176 TRUE 176 1
2 67 TRUE 67 1
3 432 TRUE 432 1
4 77 TRUE 77 1
5 275 TRUE 275 1
> On Wed, 12 Dec 2007, edward.m at psu.ac.th wrote:
>
>
>> Full_Name: Edward McNeil
>> Version: 2.6.1
>> OS: Windows
>> Submission from: (NULL) (203.170.234.5)
>>
>>
>> I want to show students how the survival object looks like in R.
>> Reproducible example:
>>
>> library(MASS)
>> data(Aids2)
>> attach(Aids2)
>> status <- status=="D"
>> stime <- death-diag
>> surv <- Surv(stime, status)
>> D <- data.frame(stime, status, surv)
>> head(D,20)
>> stime status x..i..
>> 1 176 TRUE 176
>> 2 67 TRUE 67
>> 3 432 TRUE 432
>> 4 77 TRUE 77
>> 5 275 TRUE 275
>> 6 373 TRUE 373
>> 7 389 TRUE 389
>> 8 1027 TRUE 1027
>> 9 492 TRUE 492
>> 10 434 TRUE 434
>> 11 16 TRUE 16
>> 12 308 TRUE 308
>> 13 92 TRUE 92
>> 14 265 TRUE 265
>> 15 1052 FALSE 1052+
>> 16 132 TRUE 132
>> 17 527 TRUE 527
>> 18 581 FALSE 581+
>> 19 511 FALSE 511+
>> 20 151 TRUE 151
>>
>> detach(Aids2)
>>
>> The 'surv' column is strangely labelled 'x..i..'.
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>>
>
>
--
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-devel
mailing list