Hi Everyone,

I'm running some simulations where eventually I need to table the results. The problem is, that while most simulations I have at least one predicted outcome for each of the six possible categories, sometimes the algorithm assigns all the outcomes and one category is left out. Thus when I try to add the misclassification matrices I get an error. Is there a simple way I can make sure that all my tables have the same size (with a row or column of zeros) if appropriate without a messy "if" structure checking each condition?

To be more specific,

here's my line of code for the table command and the two matrices that I sometimes have. Notice that in the second matrix, the "fad" column is missing. Basically, I want all the columns and rows to be predetermined so that no columns/rows go missing. Thanks for your help!

Kind regards,
Greg

table(y.test,PredictedTestCurrent):


      PredictedTestCurrent
y.test adi car con fad gla mas
   adi   9   0   0   0   0   0
   car   0   6   1   0   0   3
   con   1   0   3   0   0   0
   fad   0   0   0   2   5   4
   gla   0   1   0   0   6   3
   mas   0   0   0   1   4   4


      PredictedTestCurrent
y.test adi car con gla mas
   adi   8   0   0   0   0
   car   0   8   0   0   1
   con   2   0   3   0   0
   fad   0   1   0   4   7
   gla   0   0   0   3   5
   mas   0   2   0   6   3




	[[alternative HTML version deleted]]

