Skip to content
Prev 351210 / 398502 Next

How to pass a variable to a function which use variable name as a parameter

One way to use variable names in functions like Predict() that
do not evaluate their arguments in the standard way is to use
do.call() along with as.name().  E.g.,
  varName<-"age"
  do.call("Predict", list(fit, as.name(varName), np=4))})
gives the same result as
  Predict(fit, age, np=4)



Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Tue, May 26, 2015 at 3:14 AM, wong jane <jane.wong083 at gmail.com> wrote: