as_yearquarter {grates} | R Documentation |
Coerce an object to year-quarter
Description
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.
Usage
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, ...)
Arguments
x |
R object |
... |
Only used For character input where additional arguments are passed through
to |
Value
A <grates_yearquarter>
object.
Note
Internally <grates_yearquarter>
objects are stored as the number of
quarters (starting at 0) since the Unix Epoch (1970-01-01).
See Also
as.Date()
Examples
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")
[Package grates version 1.2.1 Index]