title: Kappa, AIC, user's and producer's accuracy from a confusion matrix
body: <p>I have a confusion matrix, from which I would like to calulate the producer's and user's accuracy, and also get the overall Kappa and AIC value. I am aware that R has several packages that allow the calulation of Cohen's kappa statistic, however I cannot find any which handles a confusion matrix (or maybe I have not searched extensively enough). My confusion matrix is a 50 x 50 matrix, therefore manual calculation would be prone to error.</p>
  
  <p>So for a sample of the matrix:</p>
  
  <pre><code>      V.1   V.2   V.3   V.4   V.5
  V.1   10     0     2     1     0
  V.2    1    12     0     0     0
  V.3    0     0     9     4     0
  V.4    0     2     0     11    3
  V.5    4     1     0     0    11
  </code></pre>
  
  <p>Therefore, the User's accuracy for V.1 would be <code>(10/13)*100%</code>. Similarly, the Producer's for V.1 <code>(10/15)*100%</code>. I would have to<code>cbind</code> a new column for User's accuracy, and <code>rbind</code> a row for Producer's accuracy.  I assume I can use <code>melt</code> from the <code>reshape2</code> package to format the data in a table that can be used to calculate the kappa. But ideally I would like to keep the data in the confusion matrix format. </p>
  
  <p>The ideal final result would look like:</p>
  
  <pre><code>      V.1   V.2   V.3   V.4   V.5  User Acc
  V.1   10     0     2     1     0     76.92
  V.2    1    12     0     0     0     92.30
  V.3    0     0     9     4     0     69.23 
  V.4    0     2     0     11    3     68.75 
  V.5    4     1     0     0    11
  Prod  66.66 
  </code></pre>
  
  <p>kappa= Value, AIC = Value</p>
  
  <p>Any pointers would be deeply appreciated</p>