[R] creating Surv object from character vector

Erik Iverson eiverson at NMDP.ORG
Tue Sep 29 21:08:38 CEST 2009


Hello, 

I have

srv <- Surv(sample(1:10), sample(0:1, 10, replace = TRUE))
srv

 [1]  1  10   2+  8   6+  7+  3   5+  4+  9+
srv.char <- as.character(srv)
srv.char

 [1] " 1 " "10 " " 2+" " 8 " " 6+" " 7+" " 3 " " 5+" " 4+" " 9+"

Is there an inverse to as.character(srv).  That is, I would like 

identical(srv, ???(srv.char)) to return TRUE, where ??? is some unknown function.  I don't think it exists, but maybe I'm wrong. I suppose it would be easy enough to roll my own... 

Thanks!
Erik Iverson 




More information about the R-help mailing list