[R] randomForest partialPlot x.var through function

From: Eric Archer <Eric.Archer_at_noaa.gov>
Date: Sat 14 May 2005 - 03:20:35 EST


I'm trying to set up a function which calls the partialPlot function but am getting an error that I can't seem to solve. Here's a simplified version of the function and error...

> pplot <-

> attach(acoust)
> acoust.rf <-


+       Lisso+FerPsu+Glob+mixspotspin+mixother+mixed+Size,
+       data=acoust,importance=TRUE,keep.forest=TRUE)

> cruise.pp <- pplot(acoust.rf,Cruise)
Error in "[.data.frame"(pred.data, , xname) :

        undefined columns selected

Here's the traceback call...

> traceback()

6: stop("undefined columns selected")
5: "[.data.frame"(pred.data, , xname)
4: pred.data[, xname]
3: partialPlot.randomForest(x = rf, pred.data = acoust, x.var = pred.var)
2: partialPlot(x = rf, pred.data = acoust, x.var = pred.var)
1: pplot(acoust.rf, Cruise)

 From the partialPlot help file, the "pred.data[, xname]" seems to apply to the "n.pt" argument which reads, "if 'x.var' is continuous, the number of points on the grid for evaluating partial dependence."

It is not clear to me what "xname" is or where it is defined. If it is supposed to be "x.var" where does it get assigned? I've tried help.search("xname") to no useful avail that I could tell. Second, in my case, "acoust$Cruise" is a factor and the line

> cruise.pp <- partialPlot(acoust.rf,acoust,Cruise)

produces the proper plot.

Which leads me to belive that I'm doing something wrong in how I'm passing "Cruise" through "pred.var" in the function call to "x.var", but I can't figure out how to properly correct it.

Thanks in advance for any pointers.



Eric Archer, Ph.D.
8604 La Jolla Shores Dr.
La Jolla, CA 92037

"Lighthouses are more helpful than churches."
    - Benjamin Franklin

"Cogita tute" - Think for yourself

R-help@stat.math.ethz.ch mailing list
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Sat May 14 03:24:40 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:45 EST