title: Extract diagonals from a distance matrix in R
body: <p>I would like to know how can I extract the values of the first diagonal from a distance matrix.</p>
  
  <p>For example:</p>
  
  <pre><code>&gt; mymatrix
       [,1] [,2]
  [1,]    1    2
  [2,]    3    4
  [3,]    6    4
  [4,]    8    6
  
  &gt; dist(mymatrix)
  
           1        2        3
  2 2.828427                  
  3 5.385165 3.000000         
  4 8.062258 5.385165 2.828427
  </code></pre>
  
  <p>I want to get in a vector the values: <code>2.828427, 3.000000, 2.828427</code></p>
  
  <p>Thanks!</p>