Hi. I want to do rpart cross-validation and dig inside the k-fold cross-validation model to see results at each fold. Cross-val lets me do this, but only for the model it selected as optimal. I want to do this for an non-optimal model with my choice of cp value, but it won't use my cp value within the trainControl statement. Is there a way to do accomplish this?
this is a scrubbed version of titanic, n= 891
df <- read.csv("https://static-resources.zybooks.com/static/titanic.csv")
colnames(df) <- "survived"
df <- subset(df, select=-c(embarked, embark_town, class, deck, alive))
df$age[is.na(df$age)] <- round(mean(df$age, na.rm = TRUE),0)
df$survived <- factor(df$survived)
train_control <- trainControl(method = "cv", number = 10)
cvmodel <- train(survived ~ ., data = df, method = "rpart", trControl = train_control)
train_control <- trainControl(method = "cv", number = 10, cp = .052632)
Error in trainControl(method = "cv", number = 10, cp = 0.052632) :
unused argument (cp = 0.052632)