View source: R/get_hour_date.R
get_hour | R Documentation |
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()
.
get_hour(x, hour_center = 0, ...)
get_date(x, hour_center = 0, ...)
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 |
Returns a period
(lubridate::as.period()
) in case of get_hour()
.
Returns a datetime object in case of get_date()
Pepijn de Vries
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.