new_yearweek {grates}R Documentation

Minimal constructor for a yearweek object

Description

new_yearweek() is a constructor for ⁠<grates_yearweek>⁠ objects aimed at developers.

Usage

new_yearweek(x = integer(), firstday = 1L)

is_yearweek(xx)

Arguments

x

⁠[integer]⁠

Vector representing the number of weeks.

double vectors will be converted via as.integer(floor(x)).

firstday

⁠[integer]⁠

The day the week starts on from 1 (Monday) to 7 (Sunday).

xx

R object.

Details

⁠<grates_yearweek>⁠ objects are stored as the number of weeks (starting at 0) from the date of the firstday nearest the Unix Epoch (1970-01-01). That is, the number of seven day periods from:

- 1969-12-29 for `firstday` equal to 1 (Monday)
- 1969-12-30 for `firstday` equal to 2 (Tuesday)
- 1969-12-31 for `firstday` equal to 3 (Wednesday)
- 1970-01-01 for `firstday` equal to 4 (Thursday)
- 1970-01-02 for `firstday` equal to 5 (Friday)
- 1970-01-03 for `firstday` equal to 6 (Saturday)
- 1970-01-04 for `firstday` equal to 7 (Sunday)

Value

A ⁠<grates_yearweek>⁠ object with subclass corresponding to the first day of the week they represent (e.g. ⁠<grates_yearweek_monday>⁠).

See Also

as_yearweek(), new_isoweek() and new_epiweek().

Examples

new_yearweek(1:10)


[Package grates version 1.2.1 Index]