I have a huge vector of timestamps (double
type in R
). This is a column in my data.table
object. I want to divide these observations into n-minutes intervals - I want to have a character
vector representing e.g. time of the first value for this interval.
For example, for 7-minutes (7*60 seconds) interval I may have:
> ts <- c(1400132530, 1400134830)
> ts.intv <- ts - (ts %% (7*60))
>
> POSIXct.intv <- as.POSIXct(ts.intv, origin="1970-01-01")
> format(POSIXct.intv, "%H:%M:%S")
[1] "07:36:00" "08:18:00"
I tried to use sapply
operation fot this procedure but it is very time-consuming over my vector of timestamps (length ~ 15kk). Can anyone sugest better solution? Any built-in function?