View source: R/metric_centroidLE.R
centroidLE | R Documentation |
This function calculates the centroid of light exposure as the mean of the time vector weighted in proportion to the corresponding binned light intensity.
centroidLE(
Light.vector,
Time.vector,
bin.size = NULL,
na.rm = FALSE,
as.df = FALSE
)
Light.vector |
Numeric vector containing the light data. |
Time.vector |
Vector containing the time data. Can be POSIXct, hms, duration, or difftime. |
bin.size |
Value specifying size of bins to average the light data over.
Must be either a duration or a duration string, e.g.,
|
na.rm |
Logical. Should missing values be removed for the calculation?
Defaults to |
as.df |
Logical. Should the output be returned as a data frame? If |
Single column data frame or vector.
Phillips, A. J. K., Clerx, W. M., O’Brien, C. S., Sano, A., Barger, L. K., Picard, R. W., Lockley, S. W., Klerman, E. B., & Czeisler, C. A. (2017). Irregular sleep/wake patterns are associated with poorer academic performance and delayed circadian and sleep/wake timing. Scientific Reports, 7(1), 3216. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1038/s41598-017-03171-4")}
Hartmeyer, S.L., Andersen, M. (2023). Towards a framework for light-dosimetry studies: Quantification metrics. Lighting Research & Technology. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1177/14771535231170500")}
Other metrics:
bright_dark_period()
,
disparity_index()
,
duration_above_threshold()
,
exponential_moving_average()
,
frequency_crossing_threshold()
,
interdaily_stability()
,
intradaily_variability()
,
midpointCE()
,
nvRC()
,
nvRD()
,
nvRD_cumulative_response()
,
period_above_threshold()
,
pulses_above_threshold()
,
threshold_for_duration()
,
timing_above_threshold()
# 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")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.