AliG AliG - 1 year ago 165
R Question

Error using survSplit function

I'm rerunning code from 2 years ago and am encountering a new error with the survSplit function. The error says that my object cannot be found, even though it is a defined column in my dataframe.

Here is an example of my dataframe:

f12 <- data.frame(id = 1:6,
next.ivl= c(22.348, 1.837, 2.051,1.782,1.692, 1.730),
event = c(0,1,1,0,1,1),
enter= rep(0,6),
end=c(22.348, 1.837,2.051,1.782,1.629,1.730))

My previous code was the following:

cutpoints.l <- c(10/12, 1.25, 1.75, 2.25, seq(3,11))

f12.split <- survSplit(f12,
cut = cutpoints.l,
event = "event",
start = "enter",
end = "next.ivl",
episode = "ivl")

I went ahead and tried running the example code provided here (also below), and am getting another error ("Error in Surv(time, status) : Time variable is not numeric." These errors seem to be related. What's going on? Why would I get an error with the example code?


FYI: currently running R version 3.3.1 (2016-06-21)

42- 42-
Answer Source

The first argument is supposed to be formula and you are giving it a data.frame. I realize this reference page appears to be a recent (even cutting edge) version looking at the URL but the current released version of pkg:survival is 2.39-5 and that page is referencing version 2.38-3. The current version of the help page for survSplit does reference an earlier version of the function which lacked a formula interface and has examples that run without error on my instance of R 3.3.1.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download