I'm having trouble calling randomForest::partialPlot programmatically. It tries to use name of the (R) variable as the data column name.
Example: library(randomForest) iris.rf <- randomForest(Species ~ ., data=iris, importance=TRUE, proximity=TRUE) partialPlot(iris.rf, iris, Sepal.Width) # works partialPlot(iris.rf, iris, "Sepal.Width") # works (function(var.name) partialPlot(iris.rf, iris, var.name))("Sepal.Width") # fails I can get around this with the following hack: (function(var.name) eval(substitute(partialPlot(iris.rf, iris, var.name), list(var.name=var.name))) )("Sepal.Width") # works But this seems like a horrible hack. Is there a "nicer" way to do this? The relevant code is: function (x, pred.data, x.var, which.class, w, plot = TRUE, add = FALSE, n.pt = min(length(unique(pred.data[, xname])), 51), rug = TRUE, xlab = deparse(substitute(x.var)), ylab = "", main = paste("Partial Dependence on", deparse(substitute(x.var))), ...) { ... x.var <- substitute(x.var) xname <- if (is.character(x.var)) x.var else { if (is.name(x.var)) deparse(x.var) else { eval(x.var) } } xv <- pred.data[, xname] ... } Thanks, Johann ______________________________________________ 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.