Datetime_limits {LightLogR} | R Documentation |
Find or set sensible limits for Datetime axis
Description
Take a vector of Datetimes
and return the start of the first and end of the
last day of data. The start
and the length
can be adjusted by
durations
, like lubridate::ddays()
. It is used in the gg_days()
function to return a sensible x-axis. This function is a thin wrapper around
lubridate::floor_date()
and lubridate::ceiling_date()
.
Usage
Datetime_limits(
x,
start = NULL,
length = NULL,
unit = "1 day",
midnight.rollover = FALSE,
...
)
Arguments
x |
a vector of |
start |
optional |
length |
optional |
unit |
a |
midnight.rollover |
a |
... |
other arguments passed to |
Value
a 2 item vector
of Datetimes
with the (adjusted) start and end of
the input vector.
Examples
dataset <- c("2023-08-15", "2023-08-20")
breaks <- Datetime_breaks(dataset)
Datetime_limits(breaks)
Datetime_limits(breaks, start = lubridate::ddays(1))
Datetime_limits(breaks, length = lubridate::ddays(2))