title: aggregate function by time and by group
body: <p>I am trying to construct a stacked bars using time per year and type. 
  My database mat (head) looks like</p>
  
  <pre><code>head(mat)
  
    year flights.type flights.duration
  1 2000         HR20         01:12:00
  2 2000         HR20         02:00:00
  3 2000           L4         00:54:00
  4 2000           L4         00:42:00
  5 2000           L4         00:22:00
  6 2000         HR20         00:24:00
  </code></pre>
  
  <p>I would like to sum flights.duration by year and by type and then construct a stacked bar.</p>
  
  <p>I tried to use the function aggregate but with time it does not work properly. Can anyone help me? My sum by year and by type looks like : </p>
  
  <pre><code>aggregate(mat$flights.duration,format(.POSIXct(mat$flights.duration,tz="GMT"), "%H:%M:%S"),FUN=sum, by=list(mat$year))
  </code></pre>