title: Aggregate / summarize multiple variables per group (e.g. sum, mean)
body: <p>From a data frame, is there a easy way to aggregate (<code>sum</code>, <code>mean</code>, <code>max</code> et c) multiple variables simultaneously?</p>
  <p>Below are some sample data:</p>
  <pre><code>library(lubridate)
  days = 365*2
  date = seq(as.Date(&quot;2000-01-01&quot;), length = days, by = &quot;day&quot;)
  year = year(date)
  month = month(date)
  x1 = cumsum(rnorm(days, 0.05)) 
  x2 = cumsum(rnorm(days, 0.05))
  df1 = data.frame(date, year, month, x1, x2)
  </code></pre>
  <p>I would like to simultaneously aggregate the <code>x1</code> and <code>x2</code> variables from the <code>df2</code> data frame by year and month.  The following code aggregates the <code>x1</code> variable, but is it also possible to simultaneously aggregate the <code>x2</code> variable?</p>
  <pre><code>### aggregate variables by year month
  df2=aggregate(x1 ~ year+month, data=df1, sum, na.rm=TRUE)
  head(df2)
  </code></pre>