as_period | R Documentation |
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, ...)
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"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.