R trouble with substitute when formula writing -


i'd iterate on formula independent variable passed string. i'm using substitute , expression don't know why it's failing.

please see following:

> coxph(substitute(survivaloutcome ~ x, list(x = as.name(colnames(combineddata)[1]))), data = combineddata) error in terms.default(formula, special, data = data) :    no terms component nor attribute   > substitute(survivaloutcome ~ x, list(x = as.name(colnames(combineddata)[1]))) survivaloutcome ~ pmm2  > coxph(survivaloutcome ~ pmm2, data = combineddata) call: coxph(formula = survivaloutcome ~ pmm2, data = combineddata)          coef exp(coef) se(coef)     z    p pmm2 0.0445      1.05    0.146 0.305 0.76  likelihood ratio test=0.09  on 1 df, p=0.761  n= 206, number of events= 129  >  > colnames(combineddata)[1] [1] "pmm2" 

as can see, expression matches perfectly, don't know why fails?


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -