title: R aggregate data column by mutliple criteria
body: <p>I'm trying to aggregate data by two categories. </p>
  
  <p><strong>data</strong></p>
  
  <pre><code>year    person  expense sex money
  2011    kevin   truck   M   1
  2011    mike    truck   M   62
  2011    sally   truck   F   60
  2012    kevin   truck   M   37
  2012    mike    truck   M   53
  2012    sally   truck   F   95
  2013    kevin   truck   M   21
  2013    mike    truck   M   13
  2013    sally   truck   F   38
  2014    kevin   truck   M   48
  2014    mike    truck   M   4
  2014    sally   truck   F   77
  2011    kevin   house   M   7
  2011    mike    house   M   94
  2011    sally   house   F   79
  2012    kevin   house   M   86
  2012    mike    house   M   42
  2012    sally   house   F   46
  2013    kevin   house   M   90
  2013    mike    house   M   76
  2013    sally   house   F   75
  2014    kevin   house   M   70
  2014    mike    house   M   91
  2014    sally   house   F   62
  </code></pre>
  
  <p>I'd like to sum the money column if year and person columns match. </p>
  
  <p><strong>desired output</strong></p>
  
  <pre><code>year    person  sex money
  2011    kevin   M   8
  2011    mike    M   156
  2011    sally   F   139
  2012    kevin   M   123
  2012    mike    M   95
  2012    sally   F   141
  2013    kevin   M   111
  2013    mike    M   89
  2013    sally   F   113
  2014    kevin   M   118
  2014    mike    M   95
  2014    sally   F   139
  </code></pre>
  
  <p>How do I do this?</p>
  
  <p>I tried <code>data_aggregated = aggregate(data$money, by = list(name = data$name), FUN = sum)</code>, but that only aggregates my data by name. I don't know how to aggregate it by both name and year. It also creates a dataframe with only two variable columns: <code>name</code> and <code>x</code>.</p>
  
  <p>I also tried concatenating the name+year into an ID variable, but that seems too tedious.</p>