These are generic parsers for year/quarter/month formats that work with
nearly all possible year/quarter formats. The only prerequisite is that
x
contains a 4-digit-year and a 1-digit-quarter or 2-digit-month and no
additional numbers.
yq(x, quiet = FALSE) qy(x, quiet = FALSE) ym(x, quiet = FALSE) my(x, quiet = FALSE)
x | a |
---|---|
quiet | a |
a date_yq
or date_ym
vector
yq("2018 1")#> [1] "2018-Q1"qy("1st Quarter 2019")#> [1] "2019-Q1"#' # Works even for filenames, as long as they contain no additional numbers yq("business_report-2018_1.pdf")#> [1] "2018-Q1"my("business_report-082018.pdf")#> [1] "2018-M08"