as_epiweek {grates}R Documentation

Coerce to a epiweek object

Description

Generic for conversion to ⁠<grates_epiweek>⁠

Usage

as_epiweek(x, ...)

## Default S3 method:
as_epiweek(x, ...)

## S3 method for class 'Date'
as_epiweek(x, ...)

## S3 method for class 'POSIXt'
as_epiweek(x, ...)

## S3 method for class 'character'
as_epiweek(x, format, tryFormats = c("%Y-%m-%d", "%Y/%m/%d"), ...)

## S3 method for class 'factor'
as_epiweek(x, format, tryFormats = c("%Y-%m-%d", "%Y/%m/%d"), ...)

Arguments

x

R object.

...

Other values passed to as.Date().

format

⁠[character]⁠

Passed to as.Date() unless format = "yearweek" in which case input is assumed to be in the form "YYYY-Wxx".

If not specified, it will try tryFormats one by one on the first non-NA element, and give an error if none works. Otherwise, the processing is via strptime() whose help page describes available conversion specifications.

tryFormats

⁠[character]⁠

Format strings to try if format is not specified.

Details

Value

A ⁠<grates_epiweek>⁠ object.

See Also

new_epiweek() and as.Date().

Examples

as_epiweek(Sys.Date())
as_epiweek(as.POSIXct("2019-03-04 01:01:01", tz = "America/New_York"))
as_epiweek("2019-05-03")
as_epiweek("2019-W12", format = "yearweek")


[Package grates version 1.2.1 Index]