I'm trying to run a regression tree in a dataset using the Train function. The dataset has numeric variables that I transformed to categorial trying to solve the error message. I'm also using the TrainControl function, again, to try to solve the error. Help!!!
library(caret)
library(rpart)
library(mlbench)
data(Dataset)
set.seed(1)
ctrl \<- trainControl(method = "cv", savePredictions = TRUE)
model_T \<- train(VALUE\~REF_DATE+Sex+`Age at admission`+`Years since admission`+`Income type`+Statistics+UOM, data = Dataset, method = 'rpart2', trControl = ctrl)
model_T
A structure of Dataset:
spec_tbl_df \[46,464 x 8\] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
$ REF_DATE : Factor w/ 11 levels "2006","2007",..: 1 2 3 4 5 6 7 8 9 10 ...
$ Sex : Factor w/ 4 levels "1","2","3","4": 1 1 1 1 1 1 1 1 1 1 ...
$ Age at admission : Factor w/ 4 levels "1","2","3","4": 4 4 4 4 4 4 4 4 4 4 ...
$ Years since admission: Factor w/ 11 levels "1","2","3","4",..: 1 1 1 1 1 1 1 1 1 1 ...
$ Income type : Factor w/ 6 levels "1","2","3","4",..: 6 6 6 6 6 6 6 6 6 6 ...
$ Statistics : Factor w/ 4 levels "1","2","3","4": 3 3 3 3 3 3 3 3 3 3 ...
$ UOM : Factor w/ 2 levels "1","2": 2 2 2 2 2 2 2 2 2 2 ...
$ VALUE : num \[1:46464\] 154640 145895 151290 155340 169745 ...