Hello there. I'm trying to turn a dataset of months worth of entrance and exit timestamps into an every-hour-on-the-hour headcount of everybody in the building. The full dataset covers months worth of entries and exits.
I'm partway there -- I figured out how to find the count of people who would be in the building at one particular time... I'm just not able to think how I would create the hour-by-hour loop to tie the headcounts to.
Sample csv (p)
rowid,arrival,departure
1,2020-07-01 00:04:23,2020-07-01 01:19:00
2,2020-07-01 00:12:57,2020-07-01 02:38:00
3,2020-07-01 00:17:35,2020-07-01 08:50:00
4,2020-07-01 00:46:30,2020-07-01 02:58:00
5,2020-07-01 00:51:07,2020-07-01 06:10:00
6,2020-07-01 01:05:03,2020-07-01 02:35:00
7,2020-07-01 01:10:22,2020-07-01 03:26:00
8,2020-07-01 02:39:24,2020-07-01 14:25:00
9,2020-07-01 02:41:53,2020-07-01 03:41:00
10,2020-07-01 02:43:34,2020-07-01 05:10:00
stayCountByHour <- p %>%
filter(mdy_hms("07-01-2020 05:00:00") %within% as.interval(arrival, departure))
length(stayCountByHour$id)
Thank you for any help