title: calculating averages and creating a column
body: <p>I have  two columns (Group and weight) and I want to calculate  the average groups and then minus each cell with this average. I want to  have a function in R , but I struggle to create it. Please can you help. Many thanks</p>
  
  <pre><code>Group   weight  Diff
  A       10     -2
  A       14      2
  B      12      -1
  B      14       1
  C      14       1
  C      12      -1
  D      12     -0.5
  D      13      0.5
  </code></pre>