title: How to calculate accuracy from table matrix
body: <p>I'm using <code>table</code> to show results from the <code>kmeans</code> cluster vs. the actual class values. </p>
  
  <p><img src="https://i.stack.imgur.com/S0XBf.png" alt="enter image description here"></p>
  
  <p>How can I calculate the % accuracy based on that table. I know how to do it manually. </p>
  
  <p>Iris-setosa had all 50 in cluster 2 while Iris-versicolor had two in the other cluster. </p>
  
  <p>Is there a way to calculate the % like <code>Incorrectly classified instances: 52%</code></p>
  
  <p>I would like to print the confusion matrix by classes and clusters. Something lke this:</p>
  
  <pre><code>   0   1  &lt;-- assigned to cluster
   380 120 | 1
   135 133 | 0
  
  Cluster 0 &lt;-- 1
  Cluster 1 &lt;-- 0
  
  Incorrectly clustered instances :   255.0    33.2031 %
  </code></pre>