1

I just was faced with the problem, that I want to add up times in a time object, but the standard stuff (colSums, sum, rowSums) isn't working.

So, I have

time<-c("00:00:01", "01:02:00", "09:30:01", "14:15:25")
library(chron)
x <- chron(times=time)

x
[1] 00:00:01 01:02:00 09:30:01 14:15:25

How can I now add up all times in x?

Pascal
  • 563
  • 1
  • 3
  • 15

1 Answers1

4

sum(x) works well for me

sum(x)
Time in days:
[1] 1.032951
Jilber Urbina
  • 58,147
  • 10
  • 114
  • 138
  • 3
    Ouh great, I just figured out why I always got the `Error in sum(x) : method not defined for times argument` error. The `matlab` packages was loaded. After detaching it, it works fine. – Pascal Nov 16 '12 at 13:04
  • 1
    @ Pascal, that's great you figured it out. Maybe post your discovery as an answer, that way if someone comes across this question in google a year from now, the answer will be more readily available – Ricardo Saporta Nov 16 '12 at 15:45