All,

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 <- function(rf,pred.var){partialPlot(x=rf,pred.data=acoust,x.var=pred.var)}
>
> attach(acoust)
> acoust.rf <- randomForest(VocalTF~Cruise+Spot+Spin+Delph+Stripe+Steno+Turs+Gramp+Lags+
+ 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.

e.

--

Eric Archer, Ph.D.
NOAA-SWFSC
8604 La Jolla Shores Dr.
La Jolla, CA 92037
858-546-7121,7003(FAX)
[EMAIL PROTECTED]


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

"Cogita tute" - Think for yourself

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to