[R] extracting from data.frames for survival analysis

Terry Therneau
Fri, 27 Jan 2012 14:24:43 -0000

--- begin included message ---
...
I am trying to perform survival analysis but continually get errors
when extracting from this data.frame:

attempt 1:
> X <- Surv(B27.vec$AgeOn,B27.vec$UV)
> survdiff(X,rho=0,data=uvf)
Error in x$terms : $ operator is invalid for atomic vectors

...
--------- end inclusion ----

As should be apparent from Gerrit Eichner's response, your problem is
that survdiff expects a formula as the first argument and you gave it a
survival object instead.
  However, the error message you got is really not helpful.  I've now
added a check to survreg that will result in a more apropos response
from the routine.

Terry Therneau