title: how do you aggregate data based on several columns?
body: <p>I have this data frame called df</p>
  
  <pre><code>dput(df)
  
  structure(list(timestamp = structure(c(1L, 1L, 2L, 2L, 2L, 3L
  ), .Label = c("6/17/2016 11:58", "6/17/2016 12:00", "6/17/2016 15:30"
  ), class = "factor"), app = structure(c(2L, 2L, 2L, 2L, 1L, 1L
  ), .Label = c("db", "web"), class = "factor"), qmanager = structure(c(3L, 
  3L, 3L, 4L, 1L, 2L), .Label = c("db01", "db02", "web01", "web04"
  ), class = "factor"), qname = structure(c(3L, 3L, 4L, 2L, 1L, 
  1L), .Label = c("dbtest101", "test02", "test101", "test102"), class = "factor"), 
      que = c(500L, 600L, 66L, 12000L, 4000L, 666L), mas = c(15000L, 
      50000L, 15000L, 175000L, 5000L, 15000L)), .Names = c("timestamp", 
  "app", "qmanager", "qname", "que", "mas"), class = "data.frame", row.names = c(NA, 
  -6L))
  </code></pre>
  
  <p>I need to aggregate this data into 5 minutes max by qname, qmanager and app.</p>
  
  <p>I am trying this:</p>
  
  <pre><code>df$timestamp &lt;- as.POSIXct(df$timestamp, format="%m/%d/%Y %H:%M")
  
  library(xts)
  df$timestamp&lt;-align.time(df$timestamp, n=60*5)
  df&lt;-aggregate(que ~ cut(df$timestamp, "5 min"), df$qname,df$qmanager, df$app df[setdiff(names(df), "timestamp")], max)
  </code></pre>
  
  <p>Not able to get it working, any ideas?</p>