Learn R Programming

LightLogR (version 0.3.8)

Datetime_breaks: Create a (shifted) sequence of Datetimes for axis breaks

Description

Take a vector of Datetimes and create a sequence of Datetimes with a given shift and interval. This is a helper function to create breaks for plotting, e.g. in gg_days(), and is best used in conjunction with Datetime_limits(). The function is a thin wrapper around seq().

Usage

Datetime_breaks(x, shift = lubridate::duration(12, "hours"), by = "1 day")

Value

a vector of Datetimes

Arguments

x

a vector of Datetimes

shift

a numeric giving the number of duration object, e.g. lubridate::duration(12, "hours")

by

a character scalar giving the unit of the interval in base::seq()

Examples

Run this code
dataset <- c("2023-08-15", "2023-08-20")
Datetime_breaks(dataset)
Datetime_breaks(dataset, shift = 0)
Datetime_breaks(dataset, by = "12 hours")

Run the code above in your browser using DataLab