title: How does one aggregate and summarize data quickly?
body: <p>I have a dataset whose headers look like so:</p>
  
  <pre><code>PID Time Site Rep Count
  </code></pre>
  
  <p>I want sum the <code>Count</code> by <code>Rep</code> for each <code>PID x Time x Site combo</code></p>
  
  <p>on the resulting data.frame, I want to get the mean value of <code>Count</code> for <code>PID x Time x Site</code> combo.</p>
  
  <p>Current function is as follows:</p>
  
  <pre><code>dummy &lt;- function (data)
  {
  A&lt;-aggregate(Count~PID+Time+Site+Rep,data=data,function(x){sum(na.omit(x))})
  B&lt;-aggregate(Count~PID+Time+Site,data=A,mean)
  return (B)
  }
  </code></pre>
  
  <p>This is painfully slow (original data.frame is <code>510000     20)</code>. Is there a way to speed this up with plyr?</p>