as_int_period()
is a generic for coercing input in to <grates_int_period>
.
Usage
as_int_period(x, n, ...)
# Default S3 method
as_int_period(x, n = 1L, ...)
# S3 method for class 'integer'
as_int_period(x, n = 1L, ...)
# S3 method for class 'double'
as_int_period(x, n = 1L, ...)
Arguments
- x
An R object.
double
vectors will be converted via as.integer(floor(x))
.
- n
[integer]
Number of consecutive integers that are being grouped.
Must be greater than 0.
- ...
Further arguments passed to or from other methods.
Value
A <grates_int_period>
object.
Note
Internally grates_int_period
objects are stored as the position, starting
at 0, of n-integer groups from 0. Here n-months is taken to mean a 'grouping
of n consecutive integers'.
Examples
as_int_period(1:10, n = 4L)
#> <grates_int_period[10]>
#> [1] [0, 3] [0, 3] [0, 3] [4, 7] [4, 7] [4, 7] [4, 7] [8, 11] [8, 11]
#> [10] [8, 11]