[R] Model Formulae Evaluation

albeam beam.andrew at gmail.com
Mon Jun 20 19:31:50 CEST 2011


Hi everyone,

Thank you for the help, I apologize for not "providing commented, minimal,
self-contained, reproducible code." I was looking for some pointers about
how to do this in general, but it would have been helpful for me to post a
specific example. Anyway, after the feedback this is the solution I have
settled on for future reference:

## Simple Linear Model Example ##
X <- c(1,2,3,4,5)
user.formula <- Y ~ a + b*X

param.values <- list(a=1.5, b=3, x=X)
eval(user.formula[[3]], envir = param.values)

#Output#
[1]  4.5  7.5 10.5 13.5 16.5

## Something a little more complicated ##
X <- c(.01,.1,1,10,25,50,100)

user.formula <- Y ~ Top - (Top-Bot)/(1+(X/b)^W)
param.values <- list(Top=100, Bot=1, b=.05, W=2, x=X)

eval(user.formula[[3]], envir = param.values)

#Output#
[1]  1.039584  4.807692 80.200000 99.753117 99.960416 99.990101 99.997525

Thanks again.

--
View this message in context: http://r.789695.n4.nabble.com/Model-Formulae-Evaluation-tp3610328p3611986.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list