Skip to contents

A calendar or fiscal year paired with a quarter, e.g. 2019Q1, 2019-Q1, Q1 2019, or FY2019Q3. The quarter digit is constrained to 1-4 and the year to a sane 1900-2099 window, so it does not swallow arbitrary tokens.

Usage

is_quarter(x)

Arguments

x

A character vector.

Value

Logical vector; TRUE for a valid year-quarter.

Examples

is_quarter(c("2019Q1", "Q3 2020", "FY2018Q4", "2019Q5", NA))
#> [1]  TRUE  TRUE  TRUE FALSE    NA