I'm new using R and I'm trying to build a decision tree. I've already used the package party
for ctree
and rpart
for rpart.
But, as I needed to do cross validation for my model I start using the caret
package since I'm able to do that by using the function `train() and the method I want to use.
library(caret)
cvCtrl <- trainControl(method = "repeatedcv", repeats = 2,
classProbs = TRUE)
ctree.installed<- train(TARGET ~ OPENING_BALANCE+ MONTHS_SINCE_EXPEDITION+
RS_DESC+SAP_STATUS+ ACTIVATION_STATUS+ ROTUL_STATUS+
SIM_STATUS+ RATE_PLAN_SEGMENT_NORM,
data=trainSet,
method = "ctree",
trControl = cvCtrl)
However, my variables OPENING_BALANCE
and MONTHS_SINCE_EXPEDITION
have some missing values and the function doesn't work because of that. I don't understand why this happens since I'm trying to build a tree. This problem doesn't occur when i'm using the other packages.
This is the error:
Error in na.fail.default(list(TARGET = c(3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, :
missing values in object
I didn't want to use na.action=pass
since I really don't want to discard those observations.
Am I doing something wrong? Why is this happening? Do you have any suggestions for this?