I have got a vector of POSIXct-data and want to calculate the difference between consecutive elements, like it is done by diff
e.g:
burst <- as.POSIXct(c("2016-11-07 17:20:52","2016-11-07 16:21:52", "2016-11-07 15:21:52", "2016-11-02 17:20:52","2016-11-02 16:21:52", "2016-11-02 15:21:52"))
conti <- as.POSIXct(c("2016-11-07 17:20:52","2016-11-06 17:20:52", "2016-11-05 17:20:52", "2016-11-04 17:20:52","2016-11-03 17:20:52", "2016-11-02 17:20:52"))
diff(burst)
diff(conti)
My problem is, that the units are not equal. I remember the function difftime
which has got a parameter called unit
but i am not able to construct a apply
-function to get a simiral behaviour like in diff
.