new_month()
is a constructor for <grates_month>
objects aimed at
developers.
Usage
new_month(x = integer(), n)
is_month(xx)
Arguments
- x
[integer]
Vector representing the number of n-months since the Unix Epoch (1970-01-01).
double
vectors will be converted viaas.integer(floor(x))
.- n
[integer]
Number of months that are being grouped. Must be greater than 1 (use
yearmonth()
for this case).- xx
R object.
Details
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'.
References
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.
Examples
new_month(1:10, 2L)
#> <grates_month[10]>
#> [1] "1970-Mar to 1970-Apr" "1970-May to 1970-Jun" "1970-Jul to 1970-Aug"
#> [4] "1970-Sep to 1970-Oct" "1970-Nov to 1970-Dec" "1971-Jan to 1971-Feb"
#> [7] "1971-Mar to 1971-Apr" "1971-May to 1971-Jun" "1971-Jul to 1971-Aug"
#> [10] "1971-Sep to 1971-Oct"