[R] Force evaluation of variable when calling partialPlot

Ben Bond-Lamberty bpbond at gmail.com
Mon Oct 4 14:37:13 CEST 2010


Dear R Users,

I'm using the randomForest package and would like to generate partial
dependence plots, one after another, for a variety of variables:

m <- randomForest( s, ... )
varnames <- c( "var1", "var2", "var3", "var4" )   # var1..4 are all in
data frame s
for( v in varnames ) {
   partialPlot( x=m, pred.data=s, x.var=v )
}

...but this doesn't work, with partialPlot complaining that it can't
find the variable "v". I think I need to force the evaluation of the
loop variable v so that partialPlot sees the correct variable names,
but am stumped after trying eval and similar functions. Any
suggestions on how to do this? Googling has not turned up anything
very useful.

Thanks,
Ben



More information about the R-help mailing list