[R] extracting from data.frames for survival analysis

Terry Therneau therneau at mayo.edu
Fri Jan 27 15:24:43 CET 2012


 --- 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



More information about the R-help mailing list