[R] survSplit with data.frame containing a Surv object

Heinz Tuechler tuechler at gmx.at
Mon Jul 13 17:35:16 CEST 2009


Dear All,

since years I am struggling with Surv objects in data.frames. The 
following seems to have to do with it.
See below the modified example from the help page of survSplit. The 
original works, as expected. If, however, a Surv object is added to 
the data.frame, each record gets doubled.
Is there some solution other than avoiding Surv objects in data.frames?

Thanks,
Heinz


require(survival)

## from the help page
aml3<-survSplit(aml,cut=c(5,10,50),end="time",start="start",
       event="status",episode="i")

summary(aml)
summary(aml3)

coxph(Surv(time,status)~x,data=aml)
## the same
coxph(Surv(start,time,status)~x,data=aml3)

## added to show doubling of records
aml.so <- aml
aml.so$surv.object <- with(aml, Surv(time, status))

aml3.so <- survSplit(aml.so ,cut=c(5,10,50),end="time",start="start",
                      event="status",episode="i")
summary(aml3.so)

sessionInfo('survival')
R version 2.9.1 Patched (2009-07-07 r48910)
i386-pc-mingw32

locale:
LC_COLLATE=German_Switzerland.1252;LC_CTYPE=German_Switzerland.1252;LC_MONETARY=German_Switzerland.1252;LC_NUMERIC=C;LC_TIME=German_Switzerland.1252

attached base packages:
character(0)

other attached packages:
[1] survival_2.35-4

loaded via a namespace (and not attached):
[1] base_2.9.1      graphics_2.9.1  grDevices_2.9.1 methods_2.9.1
[5] splines_2.9.1   stats_2.9.1     utils_2.9.1




More information about the R-help mailing list