[R] Variable names in model formula
E. S. Venkatraman
venkat at biosta.mskcc.org
Tue May 2 04:37:39 CEST 2000
I have the following problem. I have survival data (time, status) along
with several covariates (X1, X2,..., Xn). I want to fit a Cox model for
each of the covariate (univariately) and obtain the fitted probability of
survival at a fixed time point t0 and covariate value Xi0. I tried to do
this in a for loop where the index is the variable name as follows
covnames <- names(...)
for (covi in covnames) {
survout <- coxph(Surv(time,status) ~ covi, data = dataname)
print(summary(survfit(survout,newdata),t0))
}
Unfortunately "covi" is being treated as the variable name instead of
being evaluated and the coxph call gives an error. None of as.character,
eval, substitute (at least the way I called them) worked. How does one
pass on variable names to model formula?
Thanks,
Venkat
-----------------------------------------------------------------------
E. S. Venkatraman, Ph.D. Phone: (212) 639-8520 Fax: (212) 717-3137
Assistant Attending Member Memorial Sloan-Kettering Cancer Center
-----------------------------------------------------------------------
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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