edward.m at psu.ac.th
2007-Dec-12 02:15 UTC
[Rd] Adding a survival object to a data frame (PR#10510)
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..'.
ripley at stats.ox.ac.uk
2007-Dec-12 14:50 UTC
[Rd] Adding a survival object to a data frame (PR#10510)
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. 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 >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595