Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(data.table)
- library(chron)
- setDT(df1)[, .(timeinterval = paste(time1[1], time2[.N]), timecount = sum(timecount)),
- by = .(grp=cumsum(shift((times(shift(time1, type = "lead", fill = time1[.N])) -
- times(time2)) >= 0.05, fill = TRUE)) )][, grp := NULL][]
- # timeinterval timecount
- #1: 00:00:00 02:59:59 6
- #2: 08:00:00 09:59:59 4
- #3: 14:00:00 14:59:59 2
- #4: 17:00:00 17:59:59 2
- #5: 21:00:00 23:59:59 6
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement