title: Sum sub groups with dplyr
body: <p>I'm trying to sum sub groups with dplyr using mutate, but this means I need to know each row group to create a conditional. The idea is not to change the current grouping, as the code below shows:</p>
  <pre><code>mutate(mtcars, cond_disp = ifelse(vs==1,sum(disp[vs==1]),sum(disp[vs==0])))
  </code></pre>
  <p>Is there a dynamic method to achieve this?</p>