What I have:
a <- c(49, 55, '2017-11-01', '13:54:57', '2017-11-01', '14:13:46')
b <- c(173, 171, '2017-11-01', '14:16:19', '2017-11-01', '14:23:34')
c <- c(171, 173, '2017-11-01', '14:57:01', '2017-11-01', '15:05:11')
d <- c(55, 49, '2017-11-01', '15:07:07', '2017-11-01', '15:27:30')
e <- as.data.frame(t(data.frame(a, b, c, d)))
colnames(e) <- c('start', 'stop', 'fdate', 'ftime', 'tdate', 'ttime')
e
start stop fdate ftime tdate ttime
49 55 2017-11-01 13:54:57 2017-11-01 14:13:46
173 171 2017-11-01 14:16:19 2017-11-01 14:23:34
171 173 2017-11-01 14:57:01 2017-11-01 15:05:11
55 49 2017-11-01 15:07:07 2017-11-01 15:27:30
I want to combine rows in one by next condition:
if diff between ftime
and ttime
from previous row less than 30 minutes we have to write one row with:
start
from first row,
stop
from last row,
ftime
from first row,
ttime
from last row
What I want for example:
start stop fdate ftime tdate ttime
49 171 2017-11-01 13:54:57 2017-11-01 14:23:34
171 49 2017-11-01 14:57:01 2017-11-01 15:27:30
15:27:30 - 14:57:01 = 30 mins and 29 secs
) – Joseph Wood