title: R table to assess model performance--observed versus predicted class
body: <p>I'm involving a prediction of one variable with 10 levels,and I'm using rpart for classification.
  The certain code of forming the table is </p>
  
  <blockquote>
    <p>as.vector(t(table(predict(bb.rt,set[train,],type="class"),response[train])))</p>
  </blockquote>
  
  <p>But the result is bad:
                 Observed Class→</p>
  
  <p>Predicted Class
  ↓</p>
  
  <pre><code>               1    2   3   4    5  6    7 8   9   10
           1  26.0  0.0 0.6 0.0  0.0  0  0.0 0 0.0  0.2
           10  0.2  0.0 0.0 0.0  0.4  0  0.0 0 0.4 12.8
           2   0.0 45.6 0.6 1.4  0.6  0  0.0 0 0.0  0.0
           3   0.2  0.0 6.0 0.0  0.0  0  0.0 0 0.0  0.0
           4   0.0  0.2 0.0 3.4  0.0  0  0.0 0 0.0  0.0
           5   0.0  0.0 0.0 0.0 11.8  0  0.0 0 0.0  0.0
           6   0.0  0.0 0.0 0.0  0.0 19  0.0 0 0.0  0.0
           7   0.0  0.8 0.0 0.0  0.0  0 16.8 0 0.0  0.0
           8   0.0  0.0 0.0 0.0  0.0  0  0.0 4 0.0  0.0
           9   0.0  0.0 0.0 0.0  0.0  0  0.0 0 9.4  0.6
  </code></pre>
  
  <p>The predicted class is sorted in alphabetic order but the observed class is not.
  I need them sorted in the same way so that I can compair values which are on the diag(matrix) with other values. </p>