title: How to sum leading diagonal of table in R
body: <p>I have a table created using the <code>table()</code> command in R:</p>
  
  <pre><code>   y
  x    0  1  2  3  4  5  6  7  8  9
    0 23  0  0  0  0  1  0  0  0  0
    1  0 23  1  0  1  0  1  2  0  2
    2  1  1 28  0  0  0  1  0  2  2
    3  0  1  0 24  0  1  0  0  0  1
    4  1  1  0  0 34  0  3  0  0  0
    5  0  0  0  0  0 33  0  0  0  0
    6  0  0  0  0  0  2 32  0  0  0
    7  0  1  0  1  0  0  0 36  0  1
    8  1  1  1  1  0  0  0  1 20  1
    9  1  3  0  1  0  1  0  1  0 24
  </code></pre>
  
  <p>This table shows the results of a classification, and I want to sum the leading diagonal of it (the diagonal with the large numbers - like 23, 23, 28 etc). Is there a sensible/easy way to do this in R?</p>