title: Apply function to grouped variable using dplyr?
body: <p>This <a href="https://learnr.wordpress.com/2010/01/26/ggplot2-quick-heatmap-plotting/" rel="nofollow">Learning R</a> post applies a function to a column based on variable group:</p>
  
  <p>The data looks like this:</p>
  
  <pre><code> NAME, variable, value
   1   , GROUP1, 10
   2   , GROUP1, 20
   3   , GROUP2, 20
   4   , GROUP2, 30
  </code></pre>
  
  <p>I can use this function to rescale by variable:</p>
  
  <pre><code>nba.m &lt;- ddply(nba.m, .(variable), transform, rescale = rescale(value))
  </code></pre>
  
  <p>How would I perform this same calculation using the dplyr package? I've tried:</p>
  
  <pre><code>nba.m &lt;- nba.m %&gt;%group_by(variable) %&gt;% mutate(rescale=rescale(as.numeric(value)))
  </code></pre>
  
  <p>However this scales the entire "value" column without grouping by variable. Thanks,
  Matt</p>