Hi,

I wanted to do the cox model using a matrix. The following lines illustrate 
what I want to do:
--------------------------------
dat <- matrix(rnorm(30), ncol=3,dimnames = list(1:10,letters[1:3]))
Survival <- rexp(10)
Status <- ifelse(runif(10) < .7, 1, 0)
mat <- as.data.frame(cbind(dat,Survival,Status))

cmod <- coxph(Surv(Survival, Status) ~ a+b+c, mat)
---------------------------------
This works fine. However, I need to change the code so that the column headers 
( a+b+c )are passed into the coxph function on the fly. What string/object do I 
need to generate so the function works? I am trying:

# For example
chead <- "a+b+c"
cmod <- coxph(Surv(Survival, Status) ~ chead, mat)
but this gives an error since I'm passing in a string. Can I change chead to 
something so that the code works?
many thanks.


      
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org 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.

Reply via email to