Hi all,
I am trying to use rpart.predict to test rpart models built with both
numeric and character variables.  The rpart trees appear to come out fine,
but then when I try to use the rpart model to predict on a different dataset
(same variables) I get error messages that claim the character variables are
no good:

"Warning messages:
1: In model.frame.default(Terms, newdata, na.action = na.action, xlev =
attr(object,  :
  variable 'L3' is not a factor
2: In model.frame.default(Terms, newdata, na.action = na.action, xlev =
attr(object,  :
  variable 'Range' is not a factor"


When I build the original rpart models without these variables rpart.predict
will  work fine.

Example of the R code I'm using:

OVENrpart.pa <- rpart(OVENsites ~ L3 + BAavg + DBH + CACL + CanDecid +
CanRich + CanDiv + SubcanCov + SubcanDecid + SubcanRich + SubcanDiv + Size +
UpLow + Plantation + Range, data = sites1pabuild)
OVEN.pa <- predict(OVENrpart.pa, newdata = sites1patest)

"L3", "Plantation", and "Range" are all character variables, the rest are
numeric.

Thanks!
Jay

        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to