I have data with start and end date-times in POSIXct format. I want to calculate the number of hours between each start and end date-time, omitting the hours between 11 pm and 5 am from the calculation. Here is the sample data:
times <- data.frame(start = c('2021-11-01 04:08:01 EDT', '2021-11-02 08:56:06 EDT', '2021-11-04 08:59:24 EDT', '2021-11-08 17:48:37 EST'),
end = c('2021-11-01 23:44:01 EDT', '2021-11-03 11:04:01 EDT', '2021-11-05 13:25:08 EDT', '2021-11-12 04:56:03 EDT')) %>%
mutate(start = as.POSIXct(start),
end = as.POSIXct(end))
How can I do this? I am not sure how to proceed.
A way could be: