title: Flatten/denormalize the result of the R aggregate function
body: <p>I'm fairly new to R and I'm trying to use <code>aggregate</code> to perform some time series shaping on a dataframe, per subject and for each metric in my dataset. This works beautifully, but I find that the result isn't in a format that's very easy to use. I'd like to be able to transform the results back into the same format as the original dataframe.</p>
  
  <p>Using the iris dataset as an example:</p>
  
  <pre><code># Split into two data frames, one for metrics, the other for grouping
  iris_species = subset(iris, select=Species)
  iris_metrics = subset(iris, select=-Species)
  # Compute diff for each metric with respect to its species
  iris_diff = aggregate(iris_metrics, iris_species, diff)
  </code></pre>
  
  <p>I'm just using <code>diff</code> to illustrate that I have a function that shapes the time series, so I get a time series of possibly different length as a result and definitely not a single aggregate value (e.g. mean).</p>
  
  <p>I'd like to transform the result, which seems to be a matrix that has list valued cells to the original "flat" dataframe.</p>
  
  <p>I'm mostly curious about how to manage this with results from <code>aggregate</code>, but I'd be ok with solutions that do everything in <code>plyr</code> or <code>reshape</code>.</p>