N <- 60
# Dataset with 30 min < 250lx and 30min > 250lx
dataset1 <-
tibble::tibble(
Id = rep("A", N),
Datetime = lubridate::as_datetime(0) + lubridate::minutes(1:N),
MEDI = sample(c(sample(1:249, N / 2, replace = TRUE),
sample(250:1000, N / 2, replace = TRUE))),
)
dataset1 %>%
dplyr::reframe("Threshold above which for 30 mins" =
threshold_for_duration(MEDI, Datetime, duration = "30 mins"))
dataset1 %>%
dplyr::reframe("Threshold below which for 30 mins" =
threshold_for_duration(MEDI, Datetime, duration = "30 mins",
comparison = "below"))
dataset1 %>%
dplyr::reframe(threshold_for_duration(MEDI, Datetime, duration = "30 mins",
as.df = TRUE))
Run the code above in your browser using DataLab