int_period_class | R Documentation |
<grates_int_period>
objects represent groupings of n
consecutive integers
from 0
.
## 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, ...)
new_int_period(x = integer(), n = 1L)
is_int_period(xx)
as_int_period(x, n, ...)
x , xx |
R objects. For For
|
n |
Number of integers that are being grouped. Must be greater than 0. |
... |
Not currently used. |
as_int_period()
is a generic for coercing input in to <grates_int_period>
objects. For numeric input it coerces it's input x
first via
x <- as.integer(floor(x))
and then via integer division by n
(i.e.
x %/% n
).
new_int_period()
is a minimal constructor for <grates_period>
objects aimed at developers. It takes, as input, the number of integer
periods and the value of n
.
A <grates_int_period>
object.
# coercion
as_int_period(1:10, n = 3)
# direct construction
stopifnot(
identical(
as_int_period(1:10, n = 3),
new_int_period(c(0, 0, 1, 1, 1, 2, 2, 2, 3, 3), n = 3)
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.