Предположим, у меня есть этот набор данных
jar_camp jar campaign start_date.time end_date.time
1_pf1.1 1 pf1.1 2019-01-05 10:34:00 2019-01-05 10:41:00
2_pf1.1 2 pf1.1 2019-01-05 10:52:34 2019-01-05 11:03:00
3_pf1.1 3 pf1.1 2019-01-05 11:11:42 2019-01-05 11:21:00
1_pf2.1 1 pf2.1 2019-01-09 10:29:19 2019-01-09 10:39:35
2_pf2.1 2 pf2.1 2019-01-09 10:42:15 2019-01-09 10:53:10
3_pf2.1 3 pf2.1 2019-01-09 10:58:35 2019-01-09 11:10:40
1_pf3.1 1 pf3.1 2019-01-15 10:11:52 2019-01-15 10:22:38
2_pf3.1 2 pf3.1 2019-01-15 10:27:38 2019-01-15 10:38:56
3_pf3.1 3 pf3.1 2019-01-15 10:42:02 2019-01-15 10:52:41
1_pf4.1 1 pf4.1 2019-01-22 09:06:29 2019-01-22 09:17:05
2_pf4.1 2 pf4.1 2019-01-22 09:21:22 2019-01-22 09:31:56
3_pf4.1 3 pf4.1 2019-01-22 09:35:00 2019-01-22 09:47:26
1_pf5.1 2 pf5.1 2019-01-29 10:48:45 2019-01-29 10:59:09
2_pf5.1 3 pf5.1 2019-01-29 11:04:44 2019-01-29 11:18:24
20_pf5.1 1 pf5.1 2019-01-29 15:05:47 2019-01-29 15:16:50
1_pf8.1 1 pf8.1 2019-03-12 08:57:45 2019-03-12 09:07:55
2_pf8.1 2 pf8.1 2019-03-12 09:12:23 2019-03-12 09:22:50
3_pf8.1 3 pf8.1 2019-03-12 09:25:58 2019-03-12 09:36:29
1_pf9.1 1 pf9.1 2019-03-27 08:11:11 2019-03-27 08:21:31
2_pf9.1 2 pf9.1 2019-03-27 08:23:16 2019-03-27 08:33:55
3_pf9.1 3 pf9.1 2019-03-27 08:35:22 2019-03-27 08:46:13
structure
(list(jar_camp = c("1_pf2.1", "2_pf2.1", "3_pf2.1", "1_pf3.1", "2_pf3.1", "3_pf3.1", "1_pf4.1", "2_pf4.1", "3_pf4.1"),
jar = c(1, 2, 3, 1, 2, 3, 1, 2, 3), campaign = c("pf2.1","pf2.1", "pf2.1", "pf3.1", "pf3.1", "pf3.1", "pf4.1", "pf4.1","pf4.1"),
start_date.time = structure(c(1547029759, 1547030535,1547031515, 1547547112, 1547548058, 1547548922, 1548147989, 1548148882, 1548149700),
class = c("POSIXct", "POSIXt"), tzone = "UTC"),
end_date.time = structure(c(1547030375, 1547031190, 1547032240,
1547547758, 1547548736, 1547549561, 1548148625, 1548149516,
1548150446),
class = c("POSIXct", "POSIXt"), tzone = "UTC")), row.names = c(NA, -9L), .internal.selfref = <pointer: 0x000001a324ab1ef0>, sorted = "stamp", class = "data.frame")
, и я для каждого "jar" (кроме "campaign" = pf1.1) хочу вычислить разницу между "start_date.time" и ближайшим «end_date.time», что <чем «start_data.time». Как бы я это сделал? Я новичок ie и в основном использую tidyverse. </p>
Большое спасибо!