# I am use caret package to do model comparion and met error message [closed]

Thanks to Zach's code.

I run R code as below and get error that cold not find "trainControl and train function"

#Use the same CV-folds for each model
require(caret)
myControl <- trainControl(method='cv', number=10, index=createFolds(y, k=10))

#Fit models
model_rpart <- train(X, y, method='rpart', trControl=myControl)
model_ctree <- train(X, y, method='ctree', trControl=myControl)
model_rf <- train(X, y, method='rf', trControl=myControl)


Would you give me some suggestion since I am a R beginner. Thank you.

-
This is strange. I ran your example with the iris dataset and it worked (caret 5.15-044 on R 2.15.2). Out of curiosity, can you post the exact error message? In any case, this question is off-topic on this site, and will be too localized for Stack Overflow. –  chl Nov 1 '12 at 17:33