title: Calculate correlation by aggregating columns of data frame
body: <p>I have the following data frame:</p>
  
  <pre><code>y &lt;- data.frame(group = letters[1:5], a = rnorm(5) , b = rnorm(5), c = rnorm(5), d = rnorm(5) )
  </code></pre>
  
  <p>How to get a data frame which gives me the correlation between columns a,b and c,d for each row?</p>
  
  <p>something like: <code>sapply(y, function(x) {cor(x[2:3],x[4:5])})</code></p>
  
  <p>Thank you,
  S</p>