# Dataset with POSIXct time vector
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))
)
dataset1 %>%
dplyr::reframe(
"Centroid of light exposure" = centroidLE(MEDI, Datetime, "2 hours")
)
# Dataset with hms time vector
dataset2 <-
tibble::tibble(
Id = rep("A", 24),
Time = hms::as_hms(lubridate::as_datetime(0) + lubridate::hours(0:23)),
MEDI = c(rep(1, 6), rep(250, 13), rep(1, 5))
)
dataset2 %>%
dplyr::reframe(
"Centroid of light exposure" = centroidLE(MEDI, Time, "2 hours")
)
# Dataset with duration time vector
dataset3 <-
tibble::tibble(
Id = rep("A", 24),
Hour = lubridate::duration(0:23, "hours"),
MEDI = c(rep(1, 6), rep(250, 13), rep(1, 5))
)
dataset3 %>%
dplyr::reframe(
"Centroid of light exposure" = centroidLE(MEDI, Hour, "2 hours")
)
Run the code above in your browser using DataLab