as_yearmonth | R Documentation |
as_yearmonth()
is a generic for coercing input in to <grates_yearmonth>
.
Character input is first parsed using as.Date()
. POSIXct and POSIXlt are
all converted, with the timezone respected.
as_yearmonth(x, ...)
## Default S3 method:
as_yearmonth(x, ...)
## S3 method for class 'Date'
as_yearmonth(x, ...)
## S3 method for class 'POSIXt'
as_yearmonth(x, ...)
## S3 method for class 'character'
as_yearmonth(x, ...)
## S3 method for class 'factor'
as_yearmonth(x, ...)
x |
R object. |
... |
Only used For character input where additional arguments are passed through
to |
A <grates_yearmonth>
object.
Internally <grates_yearmonth>
objects are stored as the number of
months (starting at 0) since the Unix Epoch (1970-01-01). Precision is only
to the month level (i.e. the day of the month is always dropped).
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.
as.Date()
as_yearmonth(Sys.Date())
as_yearmonth(as.POSIXct("2019-03-04 01:01:01", tz = "America/New_York"), interval = 2)
as_yearmonth("2019-05-03")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.