yearmonth(x = NULL, ...)
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)
#> Error in loadNamespace(x): there is no package called ‘vecvec’
# parse characters
yearmonth(c("2018 Jan", "2018-01", "2018 January"))
#> Error in loadNamespace(x): there is no package called ‘vecvec’
# seq() and arithmetic
mth <- yearmonth("2017-11")
#> Error in loadNamespace(x): there is no package called ‘vecvec’
seq(mth, length.out = 10, by = 1) # by 1 month
#> Error: object 'mth' not found
mth + 0:9
#> Error: object 'mth' not found
# display formats
format(mth, format = "%y %m")
#> Error: object 'mth' not found
# units since 1970 Jan
as.double(yearmonth("1969 Jan") + 0:24)
#> Error in loadNamespace(x): there is no package called ‘vecvec’
make_yearmonth(year = 2021, month = 10:11)
#> Error in make_yearmonth(year = 2021, month = 10:11): could not find function "make_yearmonth"
make_yearmonth(year = 2020:2021, month = 10:11)
#> Error in make_yearmonth(year = 2020:2021, month = 10:11): could not find function "make_yearmonth"