title: How to do a ´subaggregation´ of a data frame in R
body: <p>Quick question.</p>
  
  <p>This is a sampler of my dataset:</p>
  
  <pre><code> name  date size
  999321   -5   20
  999321   -5   40
  999321   59   50
  999321   59   50
  999322   -5   32
  999322   -5   45
  999322   -5   20
  999322   66   13
  999322   66   24
  999322   66   14
  999322  101   24
  999322  101   23
  999322  101   15
  </code></pre>
  
  <p>So. I wish to ´subaggregate´ the sum of the sizes according to the <code>date</code> they belong to and in turn according to the <code>name</code> they belong to. Basically I want my dataframe to become like this:</p>
  
  <pre><code>name    date  size
  999321   -5   80 {20+60)
  999321   59   100 {50+50}
  999322   -5   97 {32+45+20)
  999322   66   51 {13+24+14}
  999322  101   62 {24+23+15}
  </code></pre>
  
  <p>I wanted to make a loop function which aggregated <code>size</code> values according to <code>date</code> until the number of observations ran out, but the problem is that the number of observations that each subject has varies quite a lot (as you can see, subject 999321 has 4 observations (2 for each <code>date</code> value), but 999322 has 9 observations, and this happens in the whole sample of my dataset (4879 observations in total from 322 subjects).  </p>
  
  <p>So, how can I do this?</p>
  
  <p>Thank you</p>