title: in R: Error in is.data.frame(data) : object '' not found, C5.0 plot
body: <p>This question is similar to some other questions on Stackoverflow (<a href="https://stackoverflow.com/questions/28514482/error-in-evalexpr-envir-enclos-object-not-found-with-xyplot">here</a>, <a href="https://stackoverflow.com/questions/19891637/geom-ribbon-doesnt-work-error-in-evalexpr-envir-enclos-object-variable">here</a> and <a href="https://stackoverflow.com/questions/13664585/error-in-evalexpr-envir-enclos-contradiction">here</a>), but different enough so that I cannot extrapolate those answers to my case.</p>
  
  <p>I have a function in which I fit a C5.0 model and than try to plot the model.</p>
  
  <pre><code>train_d &lt;- globald[train_ind,c(features,21)]
  model &lt;- C5.0(binclass ~ .,data=train_d,trials=10)
  </code></pre>
  
  <p><code>binclass</code> is a column name in my training/test data (globald is a dataframe from which I subset rows with <code>_ind</code> indices and columns <code>c(3:12,21)</code>, where column 21 is named <code>binclass</code>). Fitting works well. However, when I also add the line</p>
  
  <pre><code>plot(model,trial=0)
  </code></pre>
  
  <p>then I get the following error: <code>Error in is.data.frame(data) : object 'train_d' not found</code>. </p>
  
  <p>How is it possible that when fitting the model, <code>train_d</code> is found and used correctly, but while plotting, <code>train_d</code> is nowhere to be found? And, any suggestion of how to solve this issue. Namespaces in [r] remain a mystery to me.</p>
  
  <p>A minimal running example is the following:</p>
  
  <pre><code>f &lt;- function(){
      library(C50)
      set.seed(1)
      class = c(1,2)
      d &lt;- data.frame(feature1 = sample(1:10,10,replace=TRUE), feature2 = 1:10, binclass = class)
      d$binclass &lt;- as.factor(d$binclass)
      model &lt;- C5.0(binclass ~ ., data=d)
      plot(model)   
  }
  </code></pre>
  
  <p>Calling <code>f()</code> results in the following error: <code>Error in is.data.frame(data) : object 'd' not found</code></p>
  
  <p>Edit:
  As per the answer from MrFlick, it seems that the cause of this problem is a bug in the C5.0 code. There are some workarounds are indicated by Pascal and MrFlick.</p>