the survfit() function will not accept a list, so I need a way to unlist the result of Surv() without removing information from the column. For example, using the lung data:
library(survival)
attach(lung)
lung$survObj <- with(lung, Surv(time, status ==2))
lung.2 <- lung
mylist <- list(lung,lung.2)
Here is an attempt to use lung
from my list and pass lung$survObj
into `survfit() and group by column 5 (sex):
survfit(formula = mylist[[1]][11] ~ mylist[[1]][5], data = mylist[[1]])
invalid type (list) for variable 'mylist[[1]][11]'
but given the following:
nrow(mylist[[1]][11])
228
and
length(unlist[[1]][11])
456
i.e. double!
I get the obvious complaint that I am comparing columns of unequal length.
also notice that the +
symbols are removed after unlisting which is vital to survfit().
Has anyone managed to call survfit on a list of dataframes?
thanks.