title: Use row and columns indices in matrix to extract values from matrix
body: <p>I have a Matrix A which looks like</p>
  <pre><code>A = matrix(1:9,3,3)
  A
       [,1] [,2] [,3]
  [1,]    1    4    7
  [2,]    2    5    8
  [3,]    3    6    9
  </code></pre>
  <p>and a matrix of indices of elements I am interested in. Column 1 contains row indices, and column 2 contains column indices:</p>
  <pre><code>v = matrix(c(1, 3, 2, 2, 2, 3), nrow = 3, ncol = 2)
  v
       [,1] [,2]
  [1,]    1    2
  [2,]    3    2
  [3,]    2    3
  </code></pre>
  <p>I want to use the rows and column indices in 'v' to extract numbers from 'A'; the indices correspond to the numbers 4 (<code>A[1, 2]</code>), 6 (<code>A[3, 2]</code>) and 8.</p>
  <p>How can I extract those numbers directly from 'A' without using a loop?</p>
  <p>When I use</p>
  <pre><code>A[v[ , 1], v[ , 2]]
  </code></pre>
  <p>I get</p>
  <pre><code>     [,1] [,2] [,3]
  [1,]    4    4    7
  [2,]    6    6    9
  [3,]    5    5    8
  </code></pre>
  <p>because R takes all combinations of the first and second column of 'v'.</p>
  <p>What I want is an expression which gives me directly 4, 6, 8.</p>
  <p>I could just take the diagonal elements but there must be an easier way.</p>