title: Adding fictitious levels to a dataframe
body: <p>I am trying to use the confusionMatrix() function in the caret package.
  However, that requires the test dataset and the predictions derived from the training dataset
  to have exactly the same levels. Because of data issues, it may happen that I need to add fictitious
  levels with 0 occurrences to the test dataset. Is there any way to do this?</p>
  
  <p>The reproducible toy example follows:</p>
  
  <pre><code>test &lt;- data.frame (Feature=c("1200","1000","1000"), Class = c("a","b","b"))
  predicted_model &lt;- c("a","a","b","c")
  </code></pre>
  
  <p>Obviously, </p>
  
  <pre><code>confusionMatrix(predicted_model,test$Class)
  </code></pre>
  
  <p>yields the error message, </p>
  
  <pre><code> Error in confusionMatrix.default(predicted_model, test$Class) : 
    the data cannot have more levels than the reference
  </code></pre>
  
  <p>The objective is to add a fictitious Class c to test, such that by running</p>
  
  <pre><code> table(test$Class)
  </code></pre>
  
  <p>we get:</p>
  
  <pre><code>a b c
  1 2 0
  </code></pre>
  
  <p>How would you do it? Thanks</p>