# Dataset with light > 250lx between 06:00 and 18:00
dataset1 <-
tibble::tibble(
Id = rep("A", 24),
Datetime = lubridate::as_datetime(0) + lubridate::hours(0:23),
MEDI = c(rep(1, 6), rep(250, 13), rep(1, 5))
)
# Above threshold
dataset1 %>%
dplyr::reframe(timing_above_threshold(MEDI, Datetime, "above", 250, as.df = TRUE))
# Below threshold
dataset1 %>%
dplyr::reframe(timing_above_threshold(MEDI, Datetime, "below", 10, as.df = TRUE))
# Input = HMS -> Output = HMS
dataset1 %>%
dplyr::reframe(timing_above_threshold(MEDI, hms::as_hms(Datetime), "above", 250, as.df = TRUE))
Run the code above in your browser using DataLab