title: Selecting specific elements from a matrix all at once
body: <p>Is there a way I can select a bunch of prespecified elements all at once from a matrix? Specifically, suppose I have the following matrix:</p>
  
  <pre><code>      58        59        60       62        63        64
  58  0.000000  3.772139  6.367721 8.978718 12.197210 13.401126
  59  3.772139  0.000000  3.755554 5.935946  9.592700 11.664533
  60  6.367721  3.755554  0.000000 5.999409  9.324764 11.991269
  62  8.978718  5.935946  5.999409 0.000000  3.810169  6.762802
  63 12.197210  9.592700  9.324764 3.810169  0.000000  3.796884
  64 13.401126 11.664533 11.991269 6.762802  3.796884  0.000000
  </code></pre>
  
  <p>I want to select cells [1,2], [2,3], [3,4], [4,5], [5,6]. I realize that I can reference them by index, in this case I can run:</p>
  
  <pre><code>mymatrix[c(2,9,16,23,30)]
  </code></pre>
  
  <p>However, this is not very clear from reading the code later. Is there a way I can enter the actual (row, column) reference all at once?</p>