[R] Surv object in data.frame and Design package

Heinz Tuechler tuechler at gmx.at
Thu Mar 16 12:46:36 CET 2006

Dear All,

there seems to be some strange influence of the Design package on
data.frame. If I build a data.frame containing a Surv object without
loading the package Design, the data frame is usable to coxph. If instead I
just load Design and build a data.frame afterwards, the naming of the Surv
object is different and it does not work with coxph.
(In my real application I loaded Design to use the ie.setup function.)
Even if I detach Design I cannot build a data.frame as before loading
Design. If I include the Surv object with the I() function it seems to
work, but then there appeare the problems discussed in the posting from
yesterday "Surv object in data.frame".
The problem is solvable, but I was surprised of the unexpected
difficulties, especially that detaching Design did not solve the problem.

Is it wrong to expect that R works after detaching a package as before
loading it?


Heinz Tüchler

## example
starttime <- c(0, 0, 1.5, 0, 2.5)
stoptime  <- c(1, 1.5, 2, 2.5, 3)
event     <- c(1, 0, 1, 0, 0)
ie.status <- c(0, 0, 1, 0, 1)
survobj <- Surv(starttime, stoptime, event)
df.nodesign <- data.frame(survobj, ie.status) # build df without loading

df.design <- data.frame(survobj, ie.status) # build df after loading Design
all.equal(df.nodesign, df.design)
df.afterdesign <- data.frame(survobj, ie.status) # building df after
detaching Design
rm(survobj, ie.status)
coxph(survobj~ie.status, data=df.nodesign) # works
coxph(survobj~ie.status, data=df.design) # doesn't works
coxph(survobj~ie.status, data=df.afterdesign) # doesn't works

Windows98 SE
Version 2.2.0 Patched (2005-10-31 r36100)

More information about the R-help mailing list