Learn R Programming

tsibble (version 0.9.1)

yearquarter: Represent year-quarter

Description

stable

Create or coerce using yearquarter().

Usage

yearquarter(x)

is_yearquarter(x)

Arguments

x

Other object.

Value

year-quarter (yearquarter) objects.

Display

Use format() to display yearweek, yearmonth, and yearquarter objects in required formats. Please see strptime() details for supported conversion specifications.

See Also

Other index functions: yearmonth(), yearweek()

Examples

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

# parse characters
yearquarter(c("2018 Q1", "2018 Qtr1", "2018 Quarter 1"))

# creat an empty yearquarter container
yearquarter()

# seq() and arithmetic
qtr <- yearquarter("2017 Q1")
seq(qtr, length.out = 10, by = 1) # by 1 quarter
qtr + 0:9

# display formats
format(qtr, format = "%y Qtr%q")

# units since 1970 Q1
as.double(yearquarter("1969 Q1") + 0:8)
# }

Run the code above in your browser using DataLab