This function adds a new column zt
to the input data.frame
, which contains
the datetime values in datetime_col
shifted so that lights_on_hour
becomes the new midnight (00:00:00).
Examples
df <- data.frame(
datetime_col = seq(from = as.POSIXct("2023-07-20 00:00:00", tz = "UTC"),
to = as.POSIXct("2023-07-21 00:00:00", tz = "UTC"),
by = "hour"),
value = runif(25)
)
lights_on_hour = 6
df <- add_zt(df, datetime_col, lights_on_hour)