as_yrwk: Convert an object to a yrwk

Description Usage Arguments References Examples

View source: R/yrwk.R

Description

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
as_yrwk(x, firstday = 1L, ...)

## Default S3 method:
as_yrwk(x, firstday = 1L, ...)

## S3 method for class 'yrwk'
as_yrwk(x, ...)

## S3 method for class 'Date'
as_yrwk(x, firstday = 1L, ...)

## S3 method for class 'POSIXt'
as_yrwk(x, firstday = 1L, ...)

## S3 method for class 'character'
as_yrwk(x, firstday = 1L, ...)

## S3 method for class 'factor'
as_yrwk(x, firstday = 1L, ...)

Arguments

x

'An object to coerce to yrwk.

firstday

An integer representing the day the week starts on from 1 (Monday) to 7 (Sunday).

...

Not used.

References

The algorithm to convert between dates and yrwk, builds upon the work of Xiahong Zhao in the EpiWeek package and Zhian Kamvar in the aweek package.

Examples

1
2
3
4
as_yrwk(Sys.Date())
as_yrwk(as.POSIXct("2019-03-04 01:01:01", tz = "America/New_York"))
as_yrwk("2019-05-03")
as_yrwk("2021-W03")

tjtnew/grates documentation built on Feb. 6, 2021, 6:12 p.m.