title: Calculate unique combinations of values in dataframe, and summary values
body: <p>I would like to work with unique combinations of <code>var1</code> and <code>var2</code> in my dataframe:</p>
  
  <pre><code>foo &lt;- data.frame(var1 = c(1,1,2,2,2,2,3,3,3,3,3,4,4,4,4),
                    var2 = c(1,1,1,1,2,2,1,1,2,2,2,2,2,3,3))
  </code></pre>
  
  <p>As has been noted, <code>unique(foo)</code> results in this:</p>
  
  <pre><code>      var1  var2
   1    1     1
   2    2     1
   3    2     2
   4    3     1
   5    3     2
   6    4     2
   7    4     3
  </code></pre>
  
  <p>Based on the unique combinations, how do I get:</p>
  
  <ul>
  <li><code>n</code>, the number of occurrences of a <code>var1</code> value and</li>
  <li><code>svar</code>, the sum of each <code>var1</code> value's <code>var2</code> values.</li>
  </ul>
  
  <p>The output could look like this:</p>
  
  <pre><code>      var1  n    svar
  1     1     1    1
  2     2     2    3
  3     3     2    3
  4     4     2    5
  </code></pre>