title: Problems with Confusion matrix
body: <p>Im trying to run a confusion matrix between two lists to determine the Accuracy, Sensitivity, and Specificity. I have the two lists a and b with a collection of different variables (i.e. 0/0, 1/1, 0/1). Initially, I ran into the error Error: <code>data</code> and <code>reference</code> should be factors with the same levels. and I was able to fix it by using a table in the confusion matrix but that lead to an error, Error in !all.equal(nrow(data), ncol(data)) : invalid argument type. I tried to compensate by instead using the union function(seen below) but still no luck. Im not sure what is necessarily wrong with the data?</p>
  <pre><code>predicted
     [1] &quot;1/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;0/0&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;0/1&quot; NA   
    [18] &quot;0/1&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;1/1&quot; NA    NA    NA    &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;0/1&quot;
    [35] &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; NA    &quot;0/1&quot; &quot;0/1&quot;
    [52] &quot;0/1&quot; &quot;0/0&quot; NA    &quot;0/1&quot; NA    &quot;0/1&quot; &quot;1/1&quot; NA    NA    &quot;0/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;1/1&quot; NA   
    [69] &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;0/1&quot;
    [86] &quot;1/1&quot; &quot;0/0&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;1/1&quot; NA    &quot;0/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; NA   
   [103] &quot;0/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;0/1&quot; NA    NA    &quot;0/1&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot;
  
  reference
     [1] &quot;1/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;1/1&quot;
    [18] &quot;1/1&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;0/1&quot;
    [35] &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;0/1&quot;
    [52] &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;0/1&quot;
    [69] &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;0/1&quot;
    [86] &quot;1/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot;
   [103] &quot;0/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;1/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot; &quot;0/1&quot;
  
   table(actual=a,predicted=b)
        predicted
  actual       0/0  0/1  1/1
            3    0    0    0
     0/1    0  113 1992   28
     1/1    0    5   74 1473
  &gt; cm &lt;- confusionMatrix(data = b, reference = a)
  Error: `data` and `reference` should be factors with the same levels.
  &gt; cm &lt;- confusionMatrix(table(b, a))
  Error in !all.equal(nrow(data), ncol(data)) : invalid argument type
  &gt; predicted &lt;- ExomeC$GT.Imp.15
  &gt; reference &lt;- ExomeC$GT.Exome
  &gt; 
  &gt; u &lt;- union(predicted, reference)
  &gt; t &lt;- table(factor(predicted, u), factor(reference, u))
  &gt; confusionMatrix(t)
  Error in `[.default`(data, , pos) : subscript out of bounds
  </code></pre>