title: Sum of group but keep the same value for each row in r
body: <p>I have data frame, I want to create a new variable by sum of each ID and group, if I sum normal,dimension of data reduce, my case I need to keep and repeat each row.</p>
  
  <pre><code>ID &lt;- c(rep(1,3), rep(3, 5), rep(4,4))
  Group &lt;-c(1,1,2,1,1,1,2,2,1,1,1,2)
  x &lt;- c(1:12)
  y&lt;- c(12:23)
  df &lt;- data.frame(ID,Group,x,y)
     ID Group  x  y
  1   1     1  1 12
  2   1     1  2 13
  3   1     2  3 14
  4   3     1  4 15
  5   3     1  5 16
  6   3     1  6 17
  7   3     2  7 18
  8   3     2  8 19
  9   4     1  9 20
  10  4     1 10 21
  11  4     1 11 22
  12  4     2 12 23
  </code></pre>
  
  <p>The output with 2 more variables "sumx" and "sumy". Group by (ID, Group)</p>
  
  <pre><code>   ID Group  x  y sumx sumy
  1   1     1  1 12    3   25
  2   1     1  2 13    3   25
  3   1     2  3 14    3   14
  4   3     1  4 15   15   48
  5   3     1  5 16   15   48
  6   3     1  6 17   15   48
  7   3     2  7 18   15   37
  8   3     2  8 19   15   37
  9   4     1  9 20   30   63
  10  4     1 10 21   30   63
  11  4     1 11 22   30   63
  12  4     2 12 23   12   23
  </code></pre>
  
  <p>Any Idea?</p>