title: R: Summing POSIXct-objects using tapply
body: <p>I'm trying to sum a set of POSIXct objects by a factor variable, but am getting an error that <code>sum</code> is not defined for POSIXt objects. However, it works fine if I just calculate the mean. But how can I get the summed times by group using tapply?</p>
  
  <p>Example:</p>
  
  <pre><code>data &lt;- data.frame(time = c("2:50:04", "1:24:10", "3:10:43", "1:44:26", "2:10:19", "3:01:04"),
                     group = c("A","A","A","B","B","B"))
  data$group &lt;- as.factor(data$group)
  data$time &lt;- as.POSIXct(paste("1970-01-01", data$time), format="%Y-%m-%d %H:%M:%S", tz="GMT")
  
  # works
  tapply(data$time, data$group, mean)
  
  # doesn't work
  tapply(data$time, data$group, sum)
  </code></pre>