Skip to content
Prev 37326 / 63424 Next

rbind on data.frame that contains a column that is also a data.frame

Also Surv objects are matrices and they share the same problem when 
rbind-ing data.frames.
If contained in a data.frame, Surv objects loose their class after 
rbind and therefore do not more represent Surv objects afterwards.
Using rbind with Surv objects outside of data.frames shows a similar 
problem, but not the same column names.
In conclusion, yes, matrices are common in data.frames, but not 
without problems.

Heinz

## example
library(survival)
## create example data
starttime <- rep(0,5)
stoptime  <- 1:5
event     <- c(1,0,1,1,1)
group     <- c(1,1,1,2,2)

## build Surv object
survobj <- Surv(starttime, stoptime, event)

## build data.frame with Surv object
df.test <- data.frame(survobj, group)
df.test

## rbind data.frames
rbind(df.test, df.test)

## rbind Surv objects
rbind(survobj, survobj)
At 06.08.2010 09:34 -0700, William Dunlap wrote: