>
> as.Surv <- function(x) {
> Surv(as.integer(sub("\\+", "", x)),
> as.integer(ifelse(regexpr("\\+", x) > -1, 0, 1)))
> }
>
> > identical(srv, as.Surv(srv.char))
> [1] TRUE
>
But Do NOT use "as.integer" with real data, which may contain fractions of
course. I was too eager to get identical to return TRUE because I had only
used integers in my sample dataset! Oops.
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.