title: Using predict() for a test set with different length compared to training set
body: <p>I'm training a decision tree model using rpart using the following:</p>
  
  <pre><code>model&lt;-rpart(formula, method="class", data=training)
  </code></pre>
  
  <p>Then, I'm using predict with this model on the test dataset:</p>
  
  <pre><code>predict(model, newdata=test, type="class")
  </code></pre>
  
  <p>I get the following error when I execute the command above. Note that the training and test datasets are of different lengths.</p>
  
  <pre><code>Error in model.frame.default(Terms, newdata, na.action = na.action, xlev = attr(object,  : 
  variable lengths differ (found for 'fsc_perp')
  In addition: Warning message:
  'newdata' had 28935 rows but variables found have 43408 rows
  </code></pre>
  
  <p>Any help would be appreciated. Thanks!</p>