year_week_day {clock} | R Documentation |
Calendar: year-week-day
Description
year_week_day()
constructs a calendar from the year, week number,
week day, and the start
of the week.
Using start = clock_weekdays$monday
represents the ISO week calendar and
is equivalent to using iso_year_week_day()
.
Using start = clock_weekdays$sunday
is how Epidemiologists encode their
week-based data.
Usage
year_week_day(
year,
week = NULL,
day = NULL,
hour = NULL,
minute = NULL,
second = NULL,
subsecond = NULL,
...,
start = NULL,
subsecond_precision = NULL
)
Arguments
year |
The year. Values |
week |
The week. Values If |
day |
The day of the week. Values |
hour |
The hour. Values |
minute |
The minute. Values |
second |
The second. Values |
subsecond |
The subsecond. If specified, If using milliseconds, values If using microseconds, values If using nanoseconds, values |
... |
These dots are for future extensions and must be empty. |
start |
The day to consider the start of the week. 1 = Sunday and 7 = Saturday. Use clock_weekdays for a readable way to specify the start. If |
subsecond_precision |
The precision to interpret |
Details
Fields are recycled against each other using tidyverse recycling rules.
Fields are collected in order until the first NULL
field is located. No
fields after the first NULL
field are used.
Value
A year-week-day calendar vector.
Examples
# Year-week
x <- year_week_day(2019:2025, "last")
x
# Start the week on Monday
y <- year_week_day(2019:2025, "last", start = clock_weekdays$monday)
y
# Last days of the year
as_year_month_day(set_day(x, 7))
as_year_month_day(set_day(y, 7))