title: Summarise groups across columns and rows
body: <p>I have a dataframe <code>df</code> where:</p>
  
  <pre><code> Year      Score    x1   x2   x3 
   2006      102      K    P    8   
   2006      89       L    K    P   
   2006      46       P    3    0   
   2007      76       L    2    1  
   2007      29       L    K    6   
   2008      690      P    4    4   
   2008      301      K    0    1   
   ...       ...      ..   ..   .. 
  </code></pre>
  
  <p>However, I would like it to look like this:</p>
  
  <pre><code> Year     K    P    L    K_prop  P_prop  L_prop 
   2006     191  191  135  0.37    0.37    0.26    
   2007     29        105  0.22            0.78
   2008     301  690       0.30    0.70
   ...      ..   ..   ..   ..      ..      ..
  </code></pre>
  
  <p>Where each <code>x</code> becomes a column containing the sum of that column grouped by year. I would also like another column representing each of the respective column's proportion of the total score.</p>
  
  <p><code>K_prop = K/(K+P+L)</code> ; <code>P_prop = P/(K+P+L)</code> ; <code>L_prop = L/(K+P+L)</code></p>
  
  <p>I am sorry if this is not descriptive enough, but I appreciate any and all help you have to offer!</p>