This function assigns each event to a light or dark period, then counts the number of events in each period. It requires a data frame that contains a datetime column and only pellet events.
Because dates and light cycles are not aligned (dark phase often spans more than one date), it is recommended that users call add_zt()
first and bin by zt
instead of datetime
.
Arguments
- data
A data frame that contains a datetime column and only pellet events.
- time_col
The datetime column in your data frame. You can use a bare column name. It is recommended to use the "zt" column created by
add_zt()
to ensure that the light and dark periods align correctly.- lights_on_hour
The hour (0-23) when the light period starts. Default is 7.
- lights_off_hour
The hour (0-23) when the light period ends. Default is 19.
Value
A data.frame
grouped by the original grouping variables, date and light cycle period,
with an additional column pellets
indicating the number of events in each period.
Examples
if (FALSE) { # \dontrun{
# will have light cycle split by date
read_fed(path) %>% recalculate_pellets() %>% add_zt(datetime) %>% bin_pellets_lightcycle(datetime)
read_fed(path) %>% recalculate_pellets() %>% add_zt(datetime) %>% bin_pellets_lightcycle(datetime)
# zt date will only contain full light/dark periods
read_fed(path) %>% recalculate_pellets() %>% add_zt(datetime) %>% bin_pellets_lightcycle(zt)
} # }