title: R: decision tree Error in `[.data.frame`(frame, predictors) : undefined columns selected
body: <pre><code>m = matrix(rnorm(120, 100, 10), nrow = 20, ncol = 6) %&gt;%
    data.frame()
  
  indx = 1:(0.8*nrow(m))
  
  colnames(m) = c('True', 1:(ncol(m)-1))
  
  tree(True~., data = m, subset = indx)
  </code></pre>
  
  <p>When building the decision tree model using the code above, I have the error of:</p>
  
  <p><em>Error in <code>[.data.frame</code>(frame, predictors) : undefined columns selected</em></p>
  
  <p>Is the error from my column name? The column names 1:5 indeed have meanings so I might not change easily, is there another way I could make it work?</p>
  
  <p>Thanks! </p>