title: Grouped correlation with dplyr (works only on console)
body: <p>I'm trying to use <code>dplyr</code> to calculate grouped correlations, but something is clearly wrong since the code below <strong>works only in the console</strong>:</p>
  
  <pre><code>require(dplyr)
  set.seed(123)
  xx = data.frame(group = rep(1:4, 100), a = rnorm(400) , b = rnorm(400))
  gp = group_by(xx, group)
  summarize(gp, cor(a, b))
  
    group   cor(a, b)
  1     1 -0.02073084
  2     2  0.12803353
  3     3  0.06236264
  4     4 -0.06181904
  </code></pre>
  
  <p>If i use the same code in RStudio, i get:</p>
  
  <pre><code>   cor(a, b)
  1 0.02739193
  </code></pre>
  
  <p>What's happening?</p>