yearmonth | R Documentation |
stable
Create or coerce using yearmonth()
.
yearmonth(x, ...) make_yearmonth(year = 1970L, month = 1L) ## S3 method for class 'character' yearmonth(x, format = NULL, ...) is_yearmonth(x)
x |
Other object. |
... |
Further arguments to methods. |
year, month |
A vector of numerics give years and months. |
format |
A vector of strings to specify additional formats of |
year-month (yearmonth
) objects.
Use format()
to display yearweek
, yearmonth
, and yearquarter
objects
in required formats.
Please see strptime()
details for supported conversion specifications.
scale_x_yearmonth and others for ggplot2 scales
Other index functions:
yearquarter()
,
yearweek()
# coerce POSIXct/Dates to yearmonth x <- seq(as.Date("2016-01-01"), as.Date("2016-12-31"), by = "1 month") yearmonth(x) # parse characters yearmonth(c("2018 Jan", "2018-01", "2018 January")) # seq() and arithmetic mth <- yearmonth("2017-11") seq(mth, length.out = 10, by = 1) # by 1 month mth + 0:9 # display formats format(mth, format = "%y %m") # units since 1970 Jan as.double(yearmonth("1969 Jan") + 0:24) make_yearmonth(year = 2021, month = 10:11) make_yearmonth(year = 2020:2021, month = 10:11)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.