| time_chronon | R Documentation |
This S7 generic function extracts the chronon (the smallest time granule) from a time object, such as continuous time or cyclical time representations.
time_chronon(x, ...)
x |
A time object (e.g., base::Date, base::POSIXct, |
... |
Additional arguments for methods. |
For base::Date and base::POSIXct objects the chronon is identified from the greatest common divisor of the intervals between observations, in the same way as a tsibble's interval. For example, hourly datetimes have a 1 hour chronon rather than 1 second. A multiple of a unit (e.g. 3 hours) is only used if every observation falls on a boundary of that chronon; otherwise a single unit is used so that no information is lost when converting.
A time duration() vector representing the chronon of each
value (e.g., days(1L)).
# The chronon of a Date or POSIXct object is identified from the interval
# between observations (as with tsibble's interval)
time_chronon(Sys.Date() + 0:2)
time_chronon(as.POSIXct("2024-01-01", tz = "UTC") + 3600 * 0:2)
# Without an interval, the chronon of a Date is 1 day and a POSIXct is 1 second
time_chronon(Sys.Date())
time_chronon(Sys.time())
# The chronon of a continuous time year and month is 1 month
time_chronon(yearmonth(Sys.Date()))
# The common chronon of a mixed time object is the finest chronon
time_chronon(c(yearmonth(Sys.Date()), Sys.Date()))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.