get_hour {gghourglass} | R Documentation |
Functions to split datetime into date and time of day
Description
Split a datetime object in a date component (get_date()
) and
time of day (get_hour()
) component, centred around a specific
hour of the day. They are used by stat_hourglass()
.
Usage
get_hour(x, hour_center = 0, ...)
get_date(x, hour_center = 0, ...)
Arguments
x |
A datetime object (e.g., |
hour_center |
The hour at which the time of day is centred. Default is 0, meaning midnight. -12 centres around noon of the preceding day, +12 centres around noon of the next day. |
... |
Ignored |
Value
Returns a period
(lubridate::as.period()
) in case of get_hour()
.
Returns a datetime object in case of get_date()
Author(s)
Pepijn de Vries
Examples
my_datetime <- as.POSIXct("2020-02-02 02:20:02 UTC", tz = "UTC")
get_hour(my_datetime)
get_hour(my_datetime, -12)
get_date(my_datetime)
get_date(my_datetime, -12)
## This will return the original `my_date`
get_date(my_datetime) + get_hour(my_datetime)
## This will too
get_date(my_datetime, -12) + get_hour(my_datetime, -12)
[Package gghourglass version 0.0.3 Index]