Title: | Grouped Date Classes |
---|---|
Description: | Provides a coherent interface and implementation for creating grouped date classes. This package is part of the RECON (<https://www.repidemicsconsortium.org/>) toolkit for outbreak analysis. |
Authors: | Tim Taylor [aut, cre] |
Maintainer: | Tim Taylor <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.3.0 |
Built: | 2024-11-25 15:11:12 UTC |
Source: | CRAN |
Generic for conversion to <grates_epiweek>
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"), ...)
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"), ...)
x |
R object. |
... |
Other values passed to as.Date(). |
format |
Passed to as.Date() unless 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
|
tryFormats |
Format strings to try if format is not specified. |
Date, POSIXct, and POSIXlt are converted with the timezone respected.
Character objects are first coerced to date via as.Date()
unless
format = "yearweek"
in which case input is assumed to be in the form
"YYYY-Wxx" and parsed accordingly.
A <grates_epiweek>
object.
new_epiweek()
and as.Date()
.
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")
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")
Generic for conversion to <grates_isoweek>
as_isoweek(x, ...) ## Default S3 method: as_isoweek(x, ...) ## S3 method for class 'Date' as_isoweek(x, ...) ## S3 method for class 'POSIXt' as_isoweek(x, ...) ## S3 method for class 'character' as_isoweek(x, format, tryFormats = c("%Y-%m-%d", "%Y/%m/%d"), ...) ## S3 method for class 'factor' as_isoweek(x, format, tryFormats = c("%Y-%m-%d", "%Y/%m/%d"), ...)
as_isoweek(x, ...) ## Default S3 method: as_isoweek(x, ...) ## S3 method for class 'Date' as_isoweek(x, ...) ## S3 method for class 'POSIXt' as_isoweek(x, ...) ## S3 method for class 'character' as_isoweek(x, format, tryFormats = c("%Y-%m-%d", "%Y/%m/%d"), ...) ## S3 method for class 'factor' as_isoweek(x, format, tryFormats = c("%Y-%m-%d", "%Y/%m/%d"), ...)
x |
R object. |
... |
Other values passed to as.Date(). |
format |
Passed to as.Date() unless 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
|
tryFormats |
Format strings to try if format is not specified. |
Date, POSIXct, and POSIXlt are converted with the timezone respected.
Character objects are first coerced to date via as.Date()
unless
format = "yearweek"
in which case input is assumed to be in the form
"YYYY-Wxx" and parsed accordingly.
A <grates_isoweek>
object.
new_isoweek()
and as.Date()
.
as_isoweek(Sys.Date()) as_isoweek(as.POSIXct("2019-03-04 01:01:01", tz = "America/New_York")) as_isoweek("2019-05-03") as_isoweek("2019-W12", format = "yearweek")
as_isoweek(Sys.Date()) as_isoweek(as.POSIXct("2019-03-04 01:01:01", tz = "America/New_York")) as_isoweek("2019-05-03") as_isoweek("2019-W12", format = "yearweek")
as_month()
is a generic for coercing input in to <grates_month>
.
as_month(x, n, ...) ## Default S3 method: as_month(x, n, ...) ## S3 method for class 'Date' as_month(x, n, ...) ## S3 method for class 'POSIXt' as_month(x, n, ...) ## S3 method for class 'character' as_month(x, n, ...) ## S3 method for class 'factor' as_month(x, n, ...)
as_month(x, n, ...) ## Default S3 method: as_month(x, n, ...) ## S3 method for class 'Date' as_month(x, n, ...) ## S3 method for class 'POSIXt' as_month(x, n, ...) ## S3 method for class 'character' as_month(x, n, ...) ## S3 method for class 'factor' as_month(x, n, ...)
x |
An R object. Character input is first parsed using POSIXt inputs are converted with the timezone respected. |
n |
Number of months that are being grouped. Must be greater than 1 (use
|
... |
Only used For character input where additional arguments are passed through
to |
A <grates_month>
object.
Internally grates_month
objects are stored as the position, starting at 0,
of n-month groups since the Unix Epoch (1970-01-01). Here n-months is taken
to mean a 'grouping of n consecutive months'. Precision is only to the month
level (i.e. the day of the month is always dropped).
The algorithm to convert between dates and months relative to the UNIX Epoch comes from the work of Davis Vaughan in the unreleased datea package.
as.Date()
as_month("2019-05-03", n = 4L) as_month(as.POSIXct("2019-03-04 01:01:01", tz = "America/New_York"), n = 2)
as_month("2019-05-03", n = 4L) as_month(as.POSIXct("2019-03-04 01:01:01", tz = "America/New_York"), n = 2)
as_period()
is a generic for coercing input in to <grates_period>
.
as_period(x, n, ...) ## Default S3 method: as_period(x, n = 1L, offset = 0L, ...) ## S3 method for class 'Date' as_period(x, n = 1L, offset = 0L, ...) ## S3 method for class 'POSIXt' as_period(x, n = 1L, offset = 0L, ...) ## S3 method for class 'character' as_period(x, n = 1L, offset = 0L, ...) ## S3 method for class 'factor' as_period(x, n = 1L, offset = 0L, ...)
as_period(x, n, ...) ## Default S3 method: as_period(x, n = 1L, offset = 0L, ...) ## S3 method for class 'Date' as_period(x, n = 1L, offset = 0L, ...) ## S3 method for class 'POSIXt' as_period(x, n = 1L, offset = 0L, ...) ## S3 method for class 'character' as_period(x, n = 1L, offset = 0L, ...) ## S3 method for class 'factor' as_period(x, n = 1L, offset = 0L, ...)
x |
An R object:
|
n |
Number of days that are being grouped. |
... |
Only used For character input where additional arguments are passed through
to |
offset |
Value you wish to start counting periods from relative to the Unix Epoch:
|
A <grates_period>
object.
Internally grates_period
objects are stored as the integer number, starting
at 0L, of periods since the Unix Epoch (1970-01-01) and a specified offset.
Here periods are taken to mean groupings of n
consecutive days.
as.Date()
as_period("2019-05-03") as_period("2019-05-03", n = 2, offset = 1) as_period(as.POSIXct("2019-03-04 01:01:01", tz = "America/New_York"), n = 10) as_period(as.Date("2020-03-02"), n = 2L, offset = as.Date("2020-03-01"))
as_period("2019-05-03") as_period("2019-05-03", n = 2, offset = 1) as_period(as.POSIXct("2019-03-04 01:01:01", tz = "America/New_York"), n = 10) as_period(as.Date("2020-03-02"), n = 2L, offset = as.Date("2020-03-01"))
as_year()
is a generic for coercing input in to <grates_year>
.
as_year(x, ...) ## Default S3 method: as_year(x, ...) ## S3 method for class 'Date' as_year(x, ...) ## S3 method for class 'POSIXt' as_year(x, ...) ## S3 method for class 'character' as_year(x, ...) ## S3 method for class 'factor' as_year(x, ...)
as_year(x, ...) ## Default S3 method: as_year(x, ...) ## S3 method for class 'Date' as_year(x, ...) ## S3 method for class 'POSIXt' as_year(x, ...) ## S3 method for class 'character' as_year(x, ...) ## S3 method for class 'factor' as_year(x, ...)
x |
R object. Character input is first parsed using POSIXct and POSIXlt are converted with the timezone respected. |
... |
Only used For character input where additional arguments are passed through
to |
A <grates_year>
object.
as.Date()
as_year(Sys.Date()) as_year(as.POSIXct("2019-03-04 01:01:01", tz = "America/New_York"), interval = 2) as_year("2019-05-03")
as_year(Sys.Date()) as_year(as.POSIXct("2019-03-04 01:01:01", tz = "America/New_York"), interval = 2) as_year("2019-05-03")
as_yearmonth()
is a generic for coercing input in to <grates_yearmonth>
.
Character input is first parsed using as.Date()
. POSIXct and POSIXlt are
all converted, with the timezone respected.
as_yearmonth(x, ...) ## Default S3 method: as_yearmonth(x, ...) ## S3 method for class 'Date' as_yearmonth(x, ...) ## S3 method for class 'POSIXt' as_yearmonth(x, ...) ## S3 method for class 'character' as_yearmonth(x, ...) ## S3 method for class 'factor' as_yearmonth(x, ...)
as_yearmonth(x, ...) ## Default S3 method: as_yearmonth(x, ...) ## S3 method for class 'Date' as_yearmonth(x, ...) ## S3 method for class 'POSIXt' as_yearmonth(x, ...) ## S3 method for class 'character' as_yearmonth(x, ...) ## S3 method for class 'factor' as_yearmonth(x, ...)
x |
R object. |
... |
Only used For character input where additional arguments are passed through
to |
A <grates_yearmonth>
object.
Internally <grates_yearmonth>
objects are stored as the number of
months (starting at 0) since the Unix Epoch (1970-01-01). Precision is only
to the month level (i.e. the day of the month is always dropped).
The algorithm to convert between dates and months relative to the UNIX Epoch comes from the work of Davis Vaughan in the unreleased datea package.
as.Date()
as_yearmonth(Sys.Date()) as_yearmonth(as.POSIXct("2019-03-04 01:01:01", tz = "America/New_York"), interval = 2) as_yearmonth("2019-05-03")
as_yearmonth(Sys.Date()) as_yearmonth(as.POSIXct("2019-03-04 01:01:01", tz = "America/New_York"), interval = 2) as_yearmonth("2019-05-03")
as_yearquarter()
is a generic for coercing input in to <grates_yearquarter>
.
Character input is first parsed using as.Date()
. POSIXct and POSIXlt are
all converted, with the timezone respected.
as_yearquarter(x, ...) ## Default S3 method: as_yearquarter(x, ...) ## S3 method for class 'Date' as_yearquarter(x, ...) ## S3 method for class 'POSIXt' as_yearquarter(x, ...) ## S3 method for class 'character' as_yearquarter(x, ...) ## S3 method for class 'factor' as_yearquarter(x, ...)
as_yearquarter(x, ...) ## Default S3 method: as_yearquarter(x, ...) ## S3 method for class 'Date' as_yearquarter(x, ...) ## S3 method for class 'POSIXt' as_yearquarter(x, ...) ## S3 method for class 'character' as_yearquarter(x, ...) ## S3 method for class 'factor' as_yearquarter(x, ...)
x |
R object |
... |
Only used For character input where additional arguments are passed through
to |
A <grates_yearquarter>
object.
Internally <grates_yearquarter>
objects are stored as the number of
quarters (starting at 0) since the Unix Epoch (1970-01-01).
as.Date()
as_yearquarter(Sys.Date()) as_yearquarter(as.POSIXct("2019-03-04 01:01:01", tz = "America/New_York"), interval = 2) as_yearquarter("2019-05-03")
as_yearquarter(Sys.Date()) as_yearquarter(as.POSIXct("2019-03-04 01:01:01", tz = "America/New_York"), interval = 2) as_yearquarter("2019-05-03")
Generic for conversion to <grates_yearweek>.
as_yearweek(x, ...) ## Default S3 method: as_yearweek(x, ...) ## S3 method for class 'Date' as_yearweek(x, firstday = 1L, ...) ## S3 method for class 'POSIXt' as_yearweek(x, firstday = 1L, ...) ## S3 method for class 'character' as_yearweek( x, firstday = 1L, format, tryFormats = c("%Y-%m-%d", "%Y/%m/%d"), ... ) ## S3 method for class 'factor' as_yearweek( x, firstday = 1L, format, tryFormats = c("%Y-%m-%d", "%Y/%m/%d"), ... )
as_yearweek(x, ...) ## Default S3 method: as_yearweek(x, ...) ## S3 method for class 'Date' as_yearweek(x, firstday = 1L, ...) ## S3 method for class 'POSIXt' as_yearweek(x, firstday = 1L, ...) ## S3 method for class 'character' as_yearweek( x, firstday = 1L, format, tryFormats = c("%Y-%m-%d", "%Y/%m/%d"), ... ) ## S3 method for class 'factor' as_yearweek( x, firstday = 1L, format, tryFormats = c("%Y-%m-%d", "%Y/%m/%d"), ... )
x |
R object. |
... |
Other values passed to as.Date(). |
firstday |
The day the week starts on from 1 (Monday) to 7 (Sunday). |
format |
Passed to as.Date() unless 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
|
tryFormats |
Format strings to try if format is not specified. |
Date, POSIXct, and POSIXlt are converted with the timezone respected.
Character objects are first coerced to date via as.Date()
unless
format = "yearweek"
in which case input is assumed to be in the form
"YYYY-Wxx" and parsed accordingly.
A <grates_yearweek>
object.
as.Date()
and new_yearweek()
.
as_yearweek(Sys.Date()) as_yearweek(as.POSIXct("2019-03-04 01:01:01", tz = "America/New_York")) as_yearweek("2019-05-03", firstday = 5L) as_yearweek("2019-W12", format = "yearweek")
as_yearweek(Sys.Date()) as_yearweek(as.POSIXct("2019-03-04 01:01:01", tz = "America/New_York")) as_yearweek("2019-05-03", firstday = 5L) as_yearweek("2019-W12", format = "yearweek")
Utility functions for accessing the start (end) dates for each element of a grates object and also checking whether a date is contained within that range
date_start(x) date_end(x) date %during% x
date_start(x) date_end(x) date %during% x
x |
grouped date vector. |
date |
A scalar |
For date_start
and date_end
The requested start (end) dates for each
element in the input. For %during%
a logical vector indicating whether the
date was present within the range of the tested object.
dates <- as.Date("2020-01-01") + 1:14 week <- as_isoweek(dates) date_start(week) date_end(week) dates[1L] %during% week period <- as_period(dates, n = 3) date_start(period) date_end(period) dates[14L] %during% period
dates <- as.Date("2020-01-01") + 1:14 week <- as_isoweek(dates) date_start(week) date_end(week) dates[1L] %during% week period <- as_period(dates, n = 3) date_start(period) date_end(period) dates[14L] %during% period
epiweek()
is a constructor for <grates_epiweek>
objects.
epiweek(year = integer(), week = integer())
epiweek(year = integer(), week = integer())
year |
Vector representing the year associated with
|
week |
Vector representing the week associated with 'year.
|
Epiweeks are defined to start on a Sunday and <grates_epiweek>
objects are
stored as the number of weeks (starting at 0) from the first Sunday after the
Unix Epoch (1970-01-01). That is, the number of seven day periods from
1970-01-04.
Internally they have the same representation as a <grates_yearweek_sunday>
object so are akin to an alias but with a marginally more efficient
implementation.
A <grates_epiweek>
object.
as_epiweek()
and new_epiweek()
.
epiweek(year = 2000L, week = 3L)
epiweek(year = 2000L, week = 3L)
Generics and methods for accessing information about grouped date objects.
get_firstday(x, ...) ## Default S3 method: get_firstday(x, ...) ## S3 method for class 'grates_yearweek_monday' get_firstday(x, ...) ## S3 method for class 'grates_yearweek_tuesday' get_firstday(x, ...) ## S3 method for class 'grates_yearweek_wednesday' get_firstday(x, ...) ## S3 method for class 'grates_yearweek_thursday' get_firstday(x, ...) ## S3 method for class 'grates_yearweek_friday' get_firstday(x, ...) ## S3 method for class 'grates_yearweek_saturday' get_firstday(x, ...) ## S3 method for class 'grates_yearweek_sunday' get_firstday(x, ...) get_week(x, ...) ## Default S3 method: get_week(x, ...) ## S3 method for class 'grates_yearweek' get_week(x, ...) ## S3 method for class 'grates_epiweek' get_week(x, ...) ## S3 method for class 'grates_isoweek' get_week(x, ...) get_year(x, ...) ## Default S3 method: get_year(x, ...) ## S3 method for class 'grates_yearweek' get_year(x, ...) ## S3 method for class 'grates_epiweek' get_year(x, ...) ## S3 method for class 'grates_isoweek' get_year(x, ...) ## S3 method for class 'grates_yearmonth' get_year(x, ...) ## S3 method for class 'grates_yearquarter' get_year(x, ...) ## S3 method for class 'grates_year' get_year(x, ...) get_n(x, ...) ## Default S3 method: get_n(x, ...) ## S3 method for class 'grates_month' get_n(x, ...) ## S3 method for class 'grates_period' get_n(x, ...) ## S3 method for class 'grates_int_period' get_n(x, ...) get_offset(x, ...) ## Default S3 method: get_offset(x, ...) ## S3 method for class 'grates_period' get_offset(x, ...)
get_firstday(x, ...) ## Default S3 method: get_firstday(x, ...) ## S3 method for class 'grates_yearweek_monday' get_firstday(x, ...) ## S3 method for class 'grates_yearweek_tuesday' get_firstday(x, ...) ## S3 method for class 'grates_yearweek_wednesday' get_firstday(x, ...) ## S3 method for class 'grates_yearweek_thursday' get_firstday(x, ...) ## S3 method for class 'grates_yearweek_friday' get_firstday(x, ...) ## S3 method for class 'grates_yearweek_saturday' get_firstday(x, ...) ## S3 method for class 'grates_yearweek_sunday' get_firstday(x, ...) get_week(x, ...) ## Default S3 method: get_week(x, ...) ## S3 method for class 'grates_yearweek' get_week(x, ...) ## S3 method for class 'grates_epiweek' get_week(x, ...) ## S3 method for class 'grates_isoweek' get_week(x, ...) get_year(x, ...) ## Default S3 method: get_year(x, ...) ## S3 method for class 'grates_yearweek' get_year(x, ...) ## S3 method for class 'grates_epiweek' get_year(x, ...) ## S3 method for class 'grates_isoweek' get_year(x, ...) ## S3 method for class 'grates_yearmonth' get_year(x, ...) ## S3 method for class 'grates_yearquarter' get_year(x, ...) ## S3 method for class 'grates_year' get_year(x, ...) get_n(x, ...) ## Default S3 method: get_n(x, ...) ## S3 method for class 'grates_month' get_n(x, ...) ## S3 method for class 'grates_period' get_n(x, ...) ## S3 method for class 'grates_int_period' get_n(x, ...) get_offset(x, ...) ## Default S3 method: get_offset(x, ...) ## S3 method for class 'grates_period' get_offset(x, ...)
x |
R object |
... |
Not currently used |
Requested value or an error if no method available.
dates <- as.Date("2020-01-01") + 1:14 dat <- as_isoweek(dates) get_week(dat) get_year(dat)
dates <- as.Date("2020-01-01") + 1:14 dat <- as_isoweek(dates) get_week(dat) get_year(dat)
isoweek()
is a constructor for <grates_isoweek>
objects.
isoweek(year = integer(), week = integer())
isoweek(year = integer(), week = integer())
year |
Vector representing the year associated with
|
week |
Vector representing the week associated with 'year.
|
isoweeks are defined to start on a Monday and <grates_isoweek>
objects are
stored as the number of weeks (starting at 0) from the first Monday prior to
the Unix Epoch (1970-01-01). That is, the number of seven day periods from
1969-12-29.
Internally they have the same representation as a <grates_yearweek_monday>
object so are akin to an alias but with a marginally more efficient
implementation.
A <grates_isoweek>
object.
as_isoweek()
and new_isoweek()
.
isoweek(year = 2000L, week = 3L)
isoweek(year = 2000L, week = 3L)
new_epiweek()
is a constructor for <grates_epiweek>
objects aimed at
developers.
new_epiweek(x = integer()) is_epiweek(xx)
new_epiweek(x = integer()) is_epiweek(xx)
x |
Vector representing the number of weeks.
|
xx |
R object. |
Epiweeks are defined to start on a Sunday and <grates_epiweek>
objects are
stored as the number of weeks (starting at 0) from the first Sunday after the
Unix Epoch (1970-01-01). That is, the number of seven day periods from
1970-01-04.
Internally they have the same representation as a <grates_yearweek_sunday>
object so are akin to an alias but with a marginally more efficient
implementation.
A <grates_epiweek>
object.
new_yearweek()
and new_isoweek()
.
new_epiweek(1:10)
new_epiweek(1:10)
new_isoweek()
is a constructor for <grates_isoweek>
objects aimed at
developers.
new_isoweek(x = integer()) is_isoweek(xx)
new_isoweek(x = integer()) is_isoweek(xx)
x |
Vector representing the number of weeks.
|
xx |
R object. |
isoweeks are defined to start on a Monday and <grates_isoweek>
objects are
stored as the number of weeks (starting at 0) from the first Monday prior to
the Unix Epoch (1970-01-01). That is, the number of seven day periods from
1969-12-29.
Internally they have the same representation as a <grates_yearweek_monday>
object so are akin to an alias but with a marginally more efficient
implementation.
A <grates_isoweek>
object.
new_yearweek()
and new_epiweek()
.
new_isoweek(1:10)
new_isoweek(1:10)
new_month()
is a constructor for <grates_month>
objects aimed at
developers.
new_month(x = integer(), n) is_month(xx)
new_month(x = integer(), n) is_month(xx)
x |
Vector representing the number of n-months since the Unix Epoch (1970-01-01).
|
n |
Number of months that are being grouped. Must be greater than 1 (use
|
xx |
R object. |
grates_month
objects are stored as the integer number (starting at 0), of
n-month groups since the Unix Epoch (1970-01-01). Here n-months is taken to
mean a 'grouping of n consecutive months'.
A <grates_month>
object.
The algorithm to convert between dates and months relative to the UNIX Epoch comes from the work of Davis Vaughan in the unreleased datea package.
new_month(1:10, 2L)
new_month(1:10, 2L)
new_period()
is a constructor for <grates_period>
objects aimed at
developers.
new_period(x = integer(), n = 1L, offset = 0L) is_period(xx)
new_period(x = integer(), n = 1L, offset = 0L) is_period(xx)
x |
Vector representing the number of periods since the Unix Epoch (1970-01-01) and a specified offset.
|
n |
Number of days that are being grouped by. |
offset |
Value you wish to start counting groups from relative to the Unix Epoch. |
xx |
R object. |
grates_period
objects are stored as the integer number, starting at 0L, of
periods since the Unix Epoch (1970-01-01) and a specified offset. Here
periods are taken to mean groupings of n
consecutive days.
For storage and calculation purposes, offset
is scaled relative to n
.
I.e. offset <- offset %% n
and values of x
stored relative to this scaled
offset.
A <grates_period>
object.
new_period(1:10)
new_period(1:10)
new_yearmonth()
is a constructor for <grates_yearmonth>
objects aimed at
developers.
new_yearmonth(x = integer()) is_yearmonth(xx)
new_yearmonth(x = integer()) is_yearmonth(xx)
x |
Vector representing the number of months.
|
xx |
R object |
<grates_yearmonth>
objects are stored as the number of months (starting at
0) since the Unix Epoch (1970-01-01). Precision is only to the month level
(i.e. the day of the month is always dropped).
A <grates_yearmonth>
object.
The algorithm to convert between dates and months relative to the UNIX Epoch comes from the work of Davis Vaughan in the unreleased datea package
new_yearmonth(1:10)
new_yearmonth(1:10)
new_yearquarter()
is a constructor for <grates_yearquarter>
objects aimed
at developers.
new_yearquarter(x = integer()) is_yearquarter(xx)
new_yearquarter(x = integer()) is_yearquarter(xx)
x |
Vector representing the number of quarters.
|
xx |
R object. |
<yearquarter>
objects are stored as the number of quarters (starting at 0)
since the Unix Epoch (1970-01-01).
A <grates_yearquarter>
object.
new_yearquarter(1:10)
new_yearquarter(1:10)
new_yearweek()
is a constructor for <grates_yearweek>
objects aimed at
developers.
new_yearweek(x = integer(), firstday = 1L) is_yearweek(xx)
new_yearweek(x = integer(), firstday = 1L) is_yearweek(xx)
x |
Vector representing the number of weeks.
|
firstday |
The day the week starts on from 1 (Monday) to 7 (Sunday). |
xx |
R object. |
<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)
A <grates_yearweek>
object with subclass corresponding to the first
day of the week they represent (e.g. <grates_yearweek_monday>
).
as_yearweek()
, new_isoweek()
and new_epiweek()
.
new_yearweek(1:10)
new_yearweek(1:10)
Print an int_period object
## S3 method for class 'grates_int_period' print(x, ...) ## S3 method for class 'grates_int_period' format(x, ...)
## S3 method for class 'grates_int_period' print(x, ...) ## S3 method for class 'grates_int_period' format(x, ...)
x |
A |
... |
Not currently used. |
Print a month object
## S3 method for class 'grates_month' print(x, format = "%Y-%b", sep = "to", ...) ## S3 method for class 'grates_month' format(x, format = "%Y-%b", sep = "to", ...)
## S3 method for class 'grates_month' print(x, format = "%Y-%b", sep = "to", ...) ## S3 method for class 'grates_month' format(x, format = "%Y-%b", sep = "to", ...)
x |
A |
format |
The format to use for the bounds of each value. |
sep |
Where more than one month is grouped with others, |
... |
Not currently used. |
Print a period object
## S3 method for class 'grates_period' print(x, format = "%Y-%m-%d", sep = "to", ...) ## S3 method for class 'grates_period' format(x, format = "%Y-%m-%d", sep = "to", ...)
## S3 method for class 'grates_period' print(x, format = "%Y-%m-%d", sep = "to", ...) ## S3 method for class 'grates_period' format(x, format = "%Y-%m-%d", sep = "to", ...)
x |
A |
format |
The format to use for the bounds of each value. |
sep |
Where more than one day is grouped with others, |
... |
Not currently used. |
Print a year-quarter object
## S3 method for class 'grates_year' print(x, ...) ## S3 method for class 'grates_year' format(x, ...)
## S3 method for class 'grates_year' print(x, ...) ## S3 method for class 'grates_year' format(x, ...)
x |
A |
... |
Not currently used. |
Print a year-month object
## S3 method for class 'grates_yearmonth' print(x, format = "%Y-%b", ...) ## S3 method for class 'grates_yearmonth' format(x, format = "%Y-%b", ...)
## S3 method for class 'grates_yearmonth' print(x, format = "%Y-%b", ...) ## S3 method for class 'grates_yearmonth' format(x, format = "%Y-%b", ...)
x |
A |
format |
The format to use for printing. |
... |
Not currently used. |
Print a year-quarter object
## S3 method for class 'grates_yearquarter' print(x, ...) ## S3 method for class 'grates_yearquarter' format(x, ...)
## S3 method for class 'grates_yearquarter' print(x, ...) ## S3 method for class 'grates_yearquarter' format(x, ...)
x |
A |
... |
Not currently used. |
ggplot2 scale for an <grates_epiweek>
vector.
scale_x_grates_epiweek( ..., breaks = ggplot2::waiver(), n.breaks = 6L, format = NULL )
scale_x_grates_epiweek( ..., breaks = ggplot2::waiver(), n.breaks = 6L, format = NULL )
... |
Not currently used. |
breaks |
A |
n.breaks |
Approximate number of breaks calculated using Will only have an effect if |
format |
Format to use if "Date" scales are required. If NULL (default) then labels are in the standard yearweek format (YYYY-Www). If not NULL then the value is used by |
A scale for use with ggplot2.
ggplot2 scale for an <grates_isoweek>
vector.
scale_x_grates_isoweek( ..., breaks = ggplot2::waiver(), n.breaks = 6L, format = NULL )
scale_x_grates_isoweek( ..., breaks = ggplot2::waiver(), n.breaks = 6L, format = NULL )
... |
Not currently used. |
breaks |
A |
n.breaks |
Approximate number of breaks calculated using Will only have an effect if |
format |
Format to use if "Date" scales are required. If NULL (default) then labels are in the standard yearweek format (YYYY-Www). If not NULL then the value is used by |
A scale for use with ggplot2.
ggplot2 scale for a month vector.
scale_x_grates_month( ..., breaks = ggplot2::waiver(), n.breaks = 6L, format = "%Y-%m-%d", bounds_format = "%Y-%b", sep = "to", n )
scale_x_grates_month( ..., breaks = ggplot2::waiver(), n.breaks = 6L, format = "%Y-%m-%d", bounds_format = "%Y-%b", sep = "to", n )
... |
Not currently used. |
breaks |
A |
n.breaks |
Approximate number of breaks calculated using Will only have an effect if |
format |
Format to use if "Date" scales are required. If NULL then labels are centralised and of the form "lower category bound to upper category bound". If not NULL then the value is used by |
bounds_format |
Format to use for grouped date labels. Only used if |
sep |
Separator to use for grouped date labels. |
n |
Number of months used for the original grouping. |
A scale for use with ggplot2.
ggplot2 scale for an <grates_period>
vector.
scale_x_grates_period( ..., breaks = ggplot2::waiver(), n.breaks = 6L, format = "%Y-%m-%d", n, offset )
scale_x_grates_period( ..., breaks = ggplot2::waiver(), n.breaks = 6L, format = "%Y-%m-%d", n, offset )
... |
Not currently used. |
breaks |
A |
n.breaks |
Approximate number of breaks calculated using Will only have an effect if |
format |
Format to use for dates. Value is used by |
n |
Number of days in each period. |
offset |
Number of days used in original grouping for the offset from the Unix Epoch. |
A scale for use with ggplot2.
ggplot2 scale for year vector.
scale_x_grates_year( ..., breaks = ggplot2::waiver(), n.breaks = 6L, format = NULL )
scale_x_grates_year( ..., breaks = ggplot2::waiver(), n.breaks = 6L, format = NULL )
... |
Not currently used. |
breaks |
A |
n.breaks |
Approximate number of breaks calculated using Will only have an effect if |
format |
Format to use if "Date" scales are required. If not NULL then the value is used by |
A scale for use with ggplot2.
ggplot2 scale for a yearmonth vector.
scale_x_grates_yearmonth( ..., breaks = ggplot2::waiver(), n.breaks = 6L, format = NULL )
scale_x_grates_yearmonth( ..., breaks = ggplot2::waiver(), n.breaks = 6L, format = NULL )
... |
Not currently used. |
breaks |
A |
n.breaks |
Approximate number of breaks calculated using Will only have an effect if |
format |
Format to use if "Date" scales are required. If not NULL then the value is used by |
A scale for use with ggplot2.
ggplot2 scale for a yearquarter vector.
scale_x_grates_yearquarter( ..., breaks = ggplot2::waiver(), n.breaks = 6L, format = NULL )
scale_x_grates_yearquarter( ..., breaks = ggplot2::waiver(), n.breaks = 6L, format = NULL )
... |
Not currently used. |
breaks |
A |
n.breaks |
Approximate number of breaks calculated using Will only have an effect if |
format |
Format to use if "Date" scales are required. If not NULL then the value is used by |
A scale for use with ggplot2.
ggplot2 scale for an <grates_yearweek>
vector.
scale_x_grates_yearweek( ..., breaks = ggplot2::waiver(), n.breaks = 6L, firstday, format = NULL ) scale_x_grates_yearweek_monday( ..., breaks = ggplot2::waiver(), n.breaks = 6, format = NULL ) scale_x_grates_yearweek_isoweek( ..., breaks = ggplot2::waiver(), n.breaks = 6, format = NULL ) scale_x_grates_yearweek_tuesday( ..., breaks = ggplot2::waiver(), n.breaks = 6, format = NULL ) scale_x_grates_yearweek_wednesday( ..., breaks = ggplot2::waiver(), n.breaks = 6, format = NULL ) scale_x_grates_yearweek_thursday( ..., breaks = ggplot2::waiver(), n.breaks = 6, format = NULL ) scale_x_grates_yearweek_friday( ..., breaks = ggplot2::waiver(), n.breaks = 6, format = NULL ) scale_x_grates_yearweek_saturday( ..., breaks = ggplot2::waiver(), n.breaks = 6, format = NULL ) scale_x_grates_yearweek_sunday( ..., breaks = ggplot2::waiver(), n.breaks = 6, format = NULL ) scale_x_grates_yearweek_epiweek( ..., breaks = ggplot2::waiver(), n.breaks = 6, format = NULL )
scale_x_grates_yearweek( ..., breaks = ggplot2::waiver(), n.breaks = 6L, firstday, format = NULL ) scale_x_grates_yearweek_monday( ..., breaks = ggplot2::waiver(), n.breaks = 6, format = NULL ) scale_x_grates_yearweek_isoweek( ..., breaks = ggplot2::waiver(), n.breaks = 6, format = NULL ) scale_x_grates_yearweek_tuesday( ..., breaks = ggplot2::waiver(), n.breaks = 6, format = NULL ) scale_x_grates_yearweek_wednesday( ..., breaks = ggplot2::waiver(), n.breaks = 6, format = NULL ) scale_x_grates_yearweek_thursday( ..., breaks = ggplot2::waiver(), n.breaks = 6, format = NULL ) scale_x_grates_yearweek_friday( ..., breaks = ggplot2::waiver(), n.breaks = 6, format = NULL ) scale_x_grates_yearweek_saturday( ..., breaks = ggplot2::waiver(), n.breaks = 6, format = NULL ) scale_x_grates_yearweek_sunday( ..., breaks = ggplot2::waiver(), n.breaks = 6, format = NULL ) scale_x_grates_yearweek_epiweek( ..., breaks = ggplot2::waiver(), n.breaks = 6, format = NULL )
... |
Not currently used. |
breaks |
A |
n.breaks |
Approximate number of breaks calculated using Will only have an effect if |
firstday |
Integer value of the first weekday: 1 (Monday) to 7 (Sunday). |
format |
Format to use if "Date" scales are required. If NULL (default) then labels are in the standard yearweek format (YYYY-Www). If not NULL then the value is used by |
A scale for use with ggplot2.
year()
is a constructor for <grates_year>
objects.
year(x = integer()) is_year(object)
year(x = integer()) is_year(object)
x |
Vector representing the years.
|
object |
R object. |
A <grates_year>
object.
year(2011:2020)
year(2011:2020)
yearmonth()
is a constructor for <grates_yearmonth>
objects.
yearmonth(year = integer(), month = integer())
yearmonth(year = integer(), month = integer())
year |
Vector representing the year associated with
|
month |
Vector representing the month associated with 'year.
|
<grates_yearmonth>
objects are stored as the number of months (starting at
0) since the Unix Epoch (1970-01-01).
A <grates_yearmonth>
object.
as_yearmonth()
and new_yearmonth()
.
yearmonth(year = 2000L, month = 3L)
yearmonth(year = 2000L, month = 3L)
yearquarter()
is a constructor for <grates_yearquarter>
objects.
yearquarter(year = integer(), quarter = integer())
yearquarter(year = integer(), quarter = integer())
year |
Vector representing the year associated with
|
quarter |
Vector representing the quarter associated with 'year.
|
<grates_yearquarter>
objects are stored as the number of quarters (starting
at 0) since the Unix Epoch (1970-01-01).
A <grates_yearquarter>
object.
as_yearquarter()
and new_yearquarter()
.
yearquarter(year = 2000L, quarter = 3L)
yearquarter(year = 2000L, quarter = 3L)
yearweek()
is a constructor for <grates_yearweek>
objects. These are
weeks whose first day can be specified by the user.
yearweek(year = integer(), week = integer(), firstday = 1L)
yearweek(year = integer(), week = integer(), firstday = 1L)
year |
Vector representing the year associated with
|
week |
Vector representing the week associated with 'year.
|
firstday |
The day the week starts on from 1 (Monday) to 7 (Sunday). |
For yearweek objects the first week of a "year" is considered to be the first yearweek containing 4 days of the given calendar year. This means that the calendar year will sometimes be different to that of the associated yearweek object.
A <grates_yearweek>
object with subclass corresponding to the first day of
the week they represent (e.g. <grates_yearweek_monday>
).
Internally <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)
as_yearweek()
and new_yearweek()
.
yearweek(year = 2000L, week = 3L)
yearweek(year = 2000L, week = 3L)