I am having trouble with a K Fold Cross Validation in R , please see attached
sample <- sample.int(n = nrow(data), size = floor(.50*nrow(data)), replace = F) train <- data[sample, ] test <- data[-sample, ] ### Define train control for k fold cross validation train_control <- trainControl(method="cv", number=10) # Fit Naive Bayes Model model <- train(SIGNAL_FLAG~., data=data, trControl=train_control, method="nb") Summarise Results print(model)
I am getting multiple errors like
Error in na.fail.default(list(SIGNAL_FLAG = c(1L, 2L, 1L, 2L, 1L, 2L, : missing values in object
Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : contrasts can be applied only to factors with 2 or more levels
I have never touched or even seen r before this and do not have a background in stat… I could really use some help… I am leaving a link to the entire script and the data set below.