[R] Passing a string variable to Surv
Vincenzo Forgetta
vforge at po-box.mcgill.ca
Wed May 23 22:10:50 CEST 2001
Hi,
I am trying to write a function to automate multiple graph
generation. My data looks like:
Table of numeric values with the following headers:
timeM1 statusM1 xM1 timeM2 statusM2 xM2 timeM3 statusM3 xM3
1
2
3
4
5
6
Where M1,M2, M3 hve no similarity except they have a max string length
of 7. Examples are mcw0045, adl0003, lei0101.
Now, what I want to do is
Function(M1, M2, M3, datafile)
{
xnew <- readtable(datafile)
name1 <- paste("time",M1",sep"")
name2 <- paste(status",M1,sep"")
name3 <- paste("x",M1,sep"")
fit1 <- survfit(Surv(name1,name2)~name3,data=xnew)
.
.
repeat for M2 and M3
.
.
par(mfcol=c(1,3))
plot(fit1)
plot(fit2)
plot(fit3)
}
When I try to pass name1 into the Surv function it give the following
error message:
> fit <- survfit(Surv(name1,status)~x,data=xnew)
Error in Surv(name1, status) : Time variable is not numeric
I think it is no doing what I want it to do. How to I tell the function
Surv to pass the value of name2 as a string?
Thanks
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list