There is a parameter called "index" that allows the user to specify an index for cross-validation.
folds <- 4 cvIndex <- createFolds(factor(training$Y), folds, returnTrain = T) tc <- trainControl(index = cvIndex, method = 'cv', number = folds) rfFit <- train(Y ~ ., data = training, method = "rf", trControl = tc, maximize = TRUE, verbose = FALSE, ntree = 1000)
source share