I have an issue with the "extra" argument from the rpart.plot function. Basically, only "extra=1" works, all other numeric values from 2 to 4 throw an error. Using the mtcars dataset, here is the code I have that works:
Creating the tree:
library(rpart)
library(rpart.plot)
data("mtcars")
mytree <- rpart(cyl ~ ., mtcars,control=rpart.control(minsplit=1,
minbucket=1, cp = 0.001), method = "anova")
Ploting the tree, using either the rpart.plot or the prp function:
rpart.plot(mytree, extra=1)
prp(mytree, type=4, extra=1)
Now, changing the "extra=1" to "extra=2" (or 3, or 4) does not work. The error message I get is:
Error: extra=4 is illegal (for method="anova")
Now, I chose the "anova" method because the "class" method does not seem to be working with my dataset (R studio crashes basically) while the anova method works greatly.
In advance thanks a lot for all the help !
Cheers, D.
As commented, "The extra=4 option only works for class models, because "probability per class of observations in the node" (to quote the rpart.plot help page) doesn't make sense for an anova model." So the problem is more why the class method is not working for my dataset.