I try to make a decision tree with the following dataset:
RESULT EXPG_HOME R_HOME_3DAY
1 1.321 0.20
2 1.123 0.30
1 0.762 0.26
If I try this:
library(rpart)
tree <- rpart(RESULT ~ EXPG_HOME, df, method="class")
fancyRpartPlot(tree)
It works out. But when I try:
tree <- rpart(RESULT ~ R_HOME_3DAY, df, method="class")
fancyRpartPlot(tree)
I get the following error:
Error in apply(model$frame$yval2[, yval2per], 1, function(x) x[1 + x[1]]) :
dim(X) must have a positive length
Any thoughts on what goes wrong here?
Both EXPG_HOME and R_HOME_3DAY are numeric.
And this is what I get with the relevant variable:
> table(df$R_HOME_3DAY)
0 0.1 0.133333333 0.166666667 0.2 0.233333333
21 65 14 10 194 53
0.266666667 0.3 0.333333333 0.366666667 0.4 0.433333333
63 248 107 185 369 169
0.466666667 0.5 0.533333333 0.566666667 0.6 0.633333333
334 351 184 382 317 213
0.666666667 0.7 0.733333333 0.766666667 0.8 0.833333333
336 251 112 217 92 64
0.866666667 0.9 0.933333333
83 20 5