m = matrix(rnorm(120, 100, 10), nrow = 20, ncol = 6) %>%
data.frame()
indx = 1:(0.8*nrow(m))
colnames(m) = c('True', 1:(ncol(m)-1))
tree(True~., data = m, subset = indx)
When building the decision tree model using the code above, I have the error of:
Error in [.data.frame
(frame, predictors) : undefined columns selected
Is the error from my column name? The column names 1:5 indeed have meanings so I might not change easily, is there another way I could make it work?
Thanks!