File: year_week_day.Rd

package info (click to toggle)
r-cran-clock 0.7.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,856 kB
  • sloc: cpp: 19,564; sh: 17; makefile: 2
file content (106 lines) | stat: -rw-r--r-- 2,858 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/week-year-week-day.R
\name{year_week_day}
\alias{year_week_day}
\title{Calendar: year-week-day}
\usage{
year_week_day(
  year,
  week = NULL,
  day = NULL,
  hour = NULL,
  minute = NULL,
  second = NULL,
  subsecond = NULL,
  ...,
  start = NULL,
  subsecond_precision = NULL
)
}
\arguments{
\item{year}{\verb{[integer]}

The year. Values \verb{[-32767, 32767]} are generally allowed.}

\item{week}{\verb{[integer / "last" / NULL]}

The week. Values \verb{[1, 53]} are allowed.

If \code{"last"}, then the last week of the year is returned.}

\item{day}{\verb{[integer / NULL]}

The day of the week. Values \verb{[1, 7]} are allowed, with \verb{1 = start of week}
and \verb{7 = end of week}, in accordance with \code{start}.}

\item{hour}{\verb{[integer / NULL]}

The hour. Values \verb{[0, 23]} are allowed.}

\item{minute}{\verb{[integer / NULL]}

The minute. Values \verb{[0, 59]} are allowed.}

\item{second}{\verb{[integer / NULL]}

The second. Values \verb{[0, 59]} are allowed.}

\item{subsecond}{\verb{[integer / NULL]}

The subsecond. If specified, \code{subsecond_precision} must also be specified
to determine how to interpret the \code{subsecond}.

If using milliseconds, values \verb{[0, 999]} are allowed.

If using microseconds, values \verb{[0, 999999]} are allowed.

If using nanoseconds, values \verb{[0, 999999999]} are allowed.}

\item{...}{These dots are for future extensions and must be empty.}

\item{start}{\verb{[integer(1) / NULL]}

The day to consider the start of the week. 1 = Sunday and 7 = Saturday.

Use \link{clock_weekdays} for a readable way to specify the start.

If \code{NULL}, a \code{start} of Sunday will be used.}

\item{subsecond_precision}{\verb{[character(1) / NULL]}

The precision to interpret \code{subsecond} as. One of: \code{"millisecond"},
\code{"microsecond"}, or \code{"nanosecond"}.}
}
\value{
A year-week-day calendar vector.
}
\description{
\code{year_week_day()} constructs a calendar from the year, week number,
week day, and the \code{start} of the week.

Using \code{start = clock_weekdays$monday} represents the ISO week calendar and
is equivalent to using \code{\link[=iso_year_week_day]{iso_year_week_day()}}.

Using \code{start = clock_weekdays$sunday} is how Epidemiologists encode their
week-based data.
}
\details{
Fields are recycled against each other using
\link[vctrs:theory-faq-recycling]{tidyverse recycling rules}.

Fields are collected in order until the first \code{NULL} field is located. No
fields after the first \code{NULL} field are used.
}
\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))
}