Time periods are indexed by integers for efficiency and precision. Quarters are indexed as the number of quarters since the beginning of 1900: $quarter_id = (year - 1900) * 4 + quarter$.

quarter_year_labels(quarter_id)

quarter_number(quarter_id)

quarter_labels(quarter_id)

calendar_quarter_labels(calendar_quarter)

calendar_quarter_labels_short(calendar_quarter)

year_labels(quarter_id)

convert_quarter_id(year, quarter)

convert_calendar_quarter(year, quarter)

calendar_quarter_to_quarter_id(calendar_quarter)

quarter_id_to_calendar_quarter(quarter_id)

calendar_quarter_to_year(calendar_quarter)

calendar_quarter_to_quarter(calendar_quarter)

Arguments

quarter_id

vector of integer quarter IDs.

calendar_quarter

Vector of calendar quarters to convert.

year

vector of integer years.

quarter

vector of integer quarters (1,2,3,4).

Details

Quarters are labelled as "Jan-Mar", "Apr-Jun", "Jul-Sep", "Oct-Dec" instead of "Q1", "Q2", "Q3", "Q4" to avoid confusion between calendar quarters and offset fiscal year quarters.

Examples

quarter_ids <- convert_quarter_id(c(2009, 2017), c(3, 1))
quarter_ids
#> [1] 439 469
calender_quarters <- convert_calendar_quarter(c(2009, 2017), c(3, 1))
quarter_number(quarter_ids)
#> [1] 3 1
quarter_labels(quarter_ids)
#> [1] "September" "March"    
year_labels(quarter_ids)
#> [1] 2009 2017
quarter_year_labels(quarter_ids)
#> [1] "September 2009" "March 2017"    
calendar_quarter_labels("CY2015Q2")
#> [1] "June 2015"
calendar_quarter_to_year("CY2015Q2")
#> [1] 2015
calendar_quarter_to_quarter("CY2015Q2")
#> [1] "Q2"