| cyclical_time_helpers | R Documentation |
Helper functions for creating cyclical time representations. These functions create time objects that repeat within a larger time cycle, useful for identifying seasonal patterns or positions within a calendar period.
month_of_year(data, discrete = TRUE, calendar = time_calendar(data), ...)
day_of_year(data, discrete = TRUE, calendar = time_calendar(data), ...)
day_of_month(data, discrete = TRUE, calendar = time_calendar(data), ...)
time_of_day(data, discrete = TRUE, calendar = time_calendar(data), ...)
day_of_week(data, discrete = TRUE, calendar = time_calendar(data), ...)
week_of_year(data, discrete = TRUE, calendar = time_calendar(data), ...)
data |
Another object to be coerced into the specified cyclical time. |
discrete |
If |
calendar |
A calendar object specifying the calendar system to use. |
... |
Additional arguments for |
A mixtime time vector containing an mt_cyclical vector with chronon and cycle matching the function used.
day_of_week(): Represents the day position within a week (1-7) using
the ISO 8601 standard where weeks start on Monday.
day_of_month(): Represents the day position within a month (1-28, 1-29,
1-30, or 1-31 depending on the month). The chronon is one day, cycling
within a month.
day_of_year(): Represents the day position within a year (1-365 or 1-366
for leap years). The chronon is one day, cycling within a year.
week_of_year(): Represents the week position within a year (1-52 or 1-53)
using the ISO 8601 week numbering system.
month_of_year(): Represents the month position within a year (1-12).
The chronon is one month, cycling within a year.
You can create custom cyclical time representations using cyclical_time()
with any of the supported time units (see calendar_gregorian and calendar_isoweek).
For example, to create a representation for day of the month:
day_of_month <- new_cyclical_time_fn( chronon = day(1L), cycle = month(1L), default_calendar = cal_gregorian )
cyclical_time() for creating cyclical time vectors,
new_cyclical_time_fn() for creating cyclical time helper functions
month_of_year(Sys.Date())
day_of_year(Sys.Date())
day_of_week(Sys.Date())
day_of_week(as.Date("2025-12-15") + 0:6)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.