View source: R/nighttime_switch.R
| nighttime_switch | R Documentation |
Converts times before cutoff to the next day before applying .fun, which
helps summarise nighttime values spanning midnight (for example, median sleep
time).
nighttime_switch(
datetime,
.fun = stats::median,
cutoff = 12 * 60 * 60,
hms = TRUE
)
datetime |
A date-time vector coercible to |
.fun |
Summary function applied after the date shift. |
cutoff |
Cutoff in seconds since midnight. Values below cutoff are treated as belonging to the next day. |
hms |
Logical; if |
A summarised time as hms (default) or date-time.
x <- as.POSIXct(c("2024-01-01 23:00:00", "2024-01-02 01:00:00"), tz = "UTC")
nighttime_switch(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.