title: Tuning of mtry by caret returning strange value
body: <p>I tune the <code>mtry</code> parameter of <code>randomForest</code> using the <code>train</code> function from the <code>caret</code> package. There are only <code>48</code> columns in my <code>X</code> data, however <code>train</code> returns <code>mtry=50</code> as the best value whereas this is not a valid value (<code>&gt;48</code>). What is the explanation of that ?</p>
  
  <pre><code>&gt; dim(X)
  [1] 93 48
  &gt; fit &lt;- train(level~., data=data.frame(X,level), tuneLength=13) 
  &gt; fit$finalModel
  
  Call:
   randomForest(x = x, y = y, mtry = param$mtry) 
                 Type of random forest: classification
                       Number of trees: 500
  No. of variables tried at each split: 50
  
          OOB estimate of  error rate: 2.15%
  Confusion matrix:
       high low class.error
  high   81   1  0.01219512
  low     1  10  0.09090909
  </code></pre>
  
  <p>It is even worse if I don't set the <code>tuneLength</code> parameter:</p>
  
  <pre><code>&gt; fit &lt;- train(level~., data=data.frame(X,level)) 
  &gt; fit$finalModel 
  
  Call:
   randomForest(x = x, y = y, mtry = param$mtry) 
                 Type of random forest: classification
                       Number of trees: 500
  No. of variables tried at each split: 55
  
          OOB estimate of  error rate: 2.15%
  Confusion matrix:
       high low class.error
  high   81   1  0.01219512
  low     1  10  0.09090909
  </code></pre>
  
  <p>I don't provide the data cause it is confidential. But there's nothing special in these data: each column is numerical or is a factor, and there are no missing value.</p>