Learn R Programming

tsibble (version 0.1.0)

yearmonth: Represent year-month or year-quarter objects

Description

Create or coerce using yearmonth(), or yearquarter()

Usage

yearmonth(x)

yearquarter(x)

Arguments

x

Other object.

Value

Year-month (yearmonth) or year-quarter (yearquarter) objects.

Index functions

The tsibble yearmonth() and yearquarter() function preserve the time zone of the input x, contrasting to their zoo counterparts.

Details

It's a known issue that these attributes will be dropped when using group_by and mutate together. It is recommended to ungroup first, and then use mutate.

See Also

pull_interval

Examples

Run this code
# NOT RUN {
# coerce dates to yearmonth, yearquarter ----
x <- seq(as.Date("2016-01-01"), as.Date("2016-12-31"), by = "1 month")
yearmonth(x)
yearquarter(x)

# coerce numerics to yearmonth, yearquarter ----
yearmonth(seq(2010, 2017, by = 1 / 12))
yearquarter(seq(2010, 2017, by = 1 / 4))

# coerce yearmonths to yearquarter ----
y <- yearmonth(x)
yearquarter(y)
# }

Run the code above in your browser using DataLab