If you already knowhave an idea about how many trees you want to use (Breiman recommends at least 1000) and have used randomForest::tuneRF
to get an optimal mtry
value (let's use 6 as an example), then:
ctrl <- trainControl(method = "none")
set.seed(2)
rforest <- train(response ~ ., data = data_set,
method = "rf",
ntree = 1000,
trControl = ctrl,
tuneGrid = data.frame(mtry = 6))
Eduardo has answered your question above but I wanted to additionally demonstrate how you can tune the value for the number of random variables used for partitioning. When tuning a random forest, this parameter has more importance than ntree as long as ntree is sufficiently large.