I often prefer to avoid the lengths of such Date / Time classes and simply parse the string and convert them to a numeric value in minutes.
But, as always, there is usually a package with similar functionality. In this case, lubridate has a duration class that can be useful:
d <- new_duration(hour = 34,minute = 23,second = 23) d1 <- new_duration(hour = 12,minute = 12,second = 23) > d+d1 [1] 167746s (1.94d)
So you can do arithmetic with them, and you can also create a duration object by passing numeric values (in seconds) to as.duration .
source share