title: Sum of rows based on column values with factors
body: <p>I have the following dataframe;</p>
  
  <pre><code>Fruit &lt;- c("orange", "orange", "apple", "pineapple", "lemon", "apple", "orange") 
  
  Name &lt;- c("julius", "julius", "john", "mary", "kathy", "john", "julius")
  
  df &lt;- data.frame(Fruit, Name);df 
  </code></pre>
  
  <p>My aim is to have the sum of all the number of fruits eaten by each person so as to have the following table in the end;</p>
  
  <pre><code>         orange apple    pineapple  lemon
  julius    2      1      
  john             2      
  mary                        1   
  kathy     1                           1
  </code></pre>
  
  <p>I was trying out the aggregate function, but could only manage to have it output the total number of Fruits eaten by each person as follows;</p>
  
  <pre><code>df2 &lt;- aggregate(Fruit~Name,df,length); df2
  </code></pre>
  
  <p>The output being;</p>
  
  <pre><code>    Name Fruit
  1   john     2
  2 julius     3
  3  kathy     1
  4   mary     1
  </code></pre>
  
  <p>Any help will be appreciated. Thanks</p>