I have a problem figuring out how to extract the time of events that happened during another time of an event(in my case letters). I hope someone could help me out!
in short: I would like the rows of bb tibble whose start or end or both(start and end)time is within the range of aa records.
The end goal is to find how many times the letters occurred in aa tibble.
Please, do let me know if more clarifications are needed!
Thank you in advance!
aa <- tibble(
start = as.POSIXct(c("2019-05-02 07:08:49", "2019-05-02 07:09:21",
"2019-05-02 07:09:41", "2019-05-02 07:10:05",
"2019-05-02 07:24:52", "2019-05-02 07:28:50",
"2019-05-02 07:29:23", "2019-05-02 07:30:16",
"2019-05-02 07:33:13", "2019-05-02 07:33:43",
"2019-05-02 07:35:31", "2019-05-02 07:36:29",
"2019-05-02 07:38:14", "2019-05-02 07:43:26",
"2019-05-02 07:44:59", "2019-05-02 07:53:45",
"2019-05-02 07:54:28")),
end = as.POSIXct(c("2019-05-02 07:09:29", "2019-05-02 07:10:02",
"2019-05-02 07:10:17", "2019-05-02 07:10:40",
"2019-05-02 07:29:10", "2019-05-02 07:29:32",
"2019-05-02 07:30:35", "2019-05-02 07:30:53",
"2019-05-02 07:33:48", "2019-05-02 07:34:18",
"2019-05-02 07:36:06", "2019-05-02 07:38:34",
"2019-05-02 07:38:49", "2019-05-02 07:45:19",
"2019-05-02 07:45:35", "2019-05-02 07:54:20",
"2019-05-02 07:55:03")))
bb <- tibble(letters = sample(letters[1:4], 12, TRUE),
started = as.POSIXct(c("2019-05-02 07:30:23", "2019-05-02 07:30:56",
"2019-05-02 07:31:29", "2019-05-02 07:31:55",
"2019-05-02 07:32:22", "2019-05-02 07:32:48",
"2019-05-02 07:33:14", "2019-05-02 07:44:36",
"2019-05-02 07:45:11", "2019-05-02 07:45:36",
"2019-05-02 07:46:01", "2019-05-02 07:48:14"
)),
stopped = as.POSIXct(c("2019-05-02 07:30:56", "2019-05-02 07:31:29",
"2019-05-02 07:31:55", "2019-05-02 07:32:22",
"2019-05-02 07:32:48", "2019-05-02 07:33:14",
"2019-05-02 07:33:40", "2019-05-02 07:45:10",
"2019-05-02 07:45:36", "2019-05-02 07:46:01",
"2019-05-02 07:46:25", "2019-05-02 07:48:48"
)))