title: Error in { : task 1 failed - "undefined columns selected"
body: <p>I try to train the random forest as follows:</p>
  
  <pre><code>library(caret)
  library(randomForest)
  
  nfields &lt;- 5
  control &lt;- rfeControl(functions = rfFuncs,
                        method = "repeatedcv",
                        repeats = 1,
                        verbose = TRUE)
  
  fields &lt;- colnames(dtrain)[!colnames(dtrain) %in% "my_target"]
  predictors_rfe &lt;- rfe(dtrain[,fields,with=F], dtrain$my_target,
                         rfeControl = control)
  </code></pre>
  
  <p>Random forests's execution:</p>
  
  <pre><code>+(rfe) fit Fold01.Rep1 size: 120 
  -(rfe) fit Fold01.Rep1 size: 120 
  +(rfe) imp Fold01.Rep1 
  -(rfe) imp Fold01.Rep1 
  +(rfe) fit Fold01.Rep1 size:  16 
  +(rfe) fit Fold02.Rep1 size: 120 
  -(rfe) fit Fold02.Rep1 size: 120 
  +(rfe) imp Fold02.Rep1 
  -(rfe) imp Fold02.Rep1 
  +(rfe) fit Fold02.Rep1 size:  16 
  -(rfe) fit Fold02.Rep1 size:  16 
  +(rfe) fit Fold02.Rep1 size:   8 
  -(rfe) fit Fold02.Rep1 size:   8 
  +(rfe) fit Fold02.Rep1 size:   4 
  -(rfe) fit Fold02.Rep1 size:   4 
  +(rfe) fit Fold03.Rep1 size: 120 
  -(rfe) fit Fold03.Rep1 size: 120 
  +(rfe) imp Fold03.Rep1 
  # ...
  +(rfe) fit Fold10.Rep1 size:  16 
  -(rfe) fit Fold10.Rep1 size:  16 
  +(rfe) fit Fold10.Rep1 size:   8 
  -(rfe) fit Fold10.Rep1 size:   8 
  +(rfe) fit Fold10.Rep1 size:   4 
  -(rfe) fit Fold10.Rep1 size:   4 
  </code></pre>
  
  <p>Then I get the error:</p>
  
  <blockquote>
    <p>Error in { : task 1 failed - "undefined columns selected"</p>
  </blockquote>
  
  <p>From the error message I cannot understand what is wrong… Could anybody help please?</p>
  
  <p>I found out from <a href="https://github.com/topepo/caret/issues/485" rel="nofollow noreferrer">here</a> that it's a bug of <code>caret</code>. But this bug was reported and solved in 2016... I use the latest version of <code>caret</code></p>