as_tod | R Documentation |
Convert a datetime into a time of day expressed in hours, minutes or seconds from midnight in local time for a time zone. This conversion is useful when time-series data for different days needs to be compared or plotted based on the local time-of-day.
as_tod(x, unit.out = "hours", tz = NULL)
x |
a datetime object accepted by lubridate functions. |
unit.out |
character string, One of "tod_time", "hours", "minutes", or "seconds". |
tz |
character string indicating time zone to be used in output. |
A numeric vector of the same length as x
. If
unit.out = "tod_time"
an object of class "tod_time"
which
a numeric vector as with unit.out = "hours"
but with the class
attribute set to "tod_time"
, which dispatches to special
format()
and print()
methods.
solar_time
Other Time of day functions:
format.tod_time()
,
print.tod_time()
library(lubridate)
my_instants <- ymd_hms("2020-05-17 12:05:03") + days(c(0, 30))
my_instants
as_tod(my_instants)
as_tod(my_instants, unit.out = "tod_time")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.