tidyverts / tsibble

Tidy Temporal Data Frames and Tools
https://tsibble.tidyverts.org
GNU General Public License v3.0
528 stars 50 forks source link

yearquarter start #217

Closed StuieT85 closed 4 years ago

StuieT85 commented 4 years ago

The place I work at uses quarters differently than yearquarter, for example, the date 2020-04-01 would be the start of Q1 in 2020, but if I use yearquarter it shows 2021 Q1. I was wondering if there could be some sort of option to set if the year is set at the start of the year or at the end.

library(tsibble)

date <- as.Date('2020-04-01')
yearquarter(date, fiscal_start = 3)
earowang commented 4 years ago

yearquarter only handles fiscal year. If the fiscal year starts in March, 2020-03-01 will be 2021 Q1, which lubridate::quarter() agrees on.

date <- as.Date('2020-04-01')
lubridate::quarter(date, with_year = TRUE, fiscal_start = 2)
#> [1] 2021.1

Created on 2020-08-26 by the reprex package (v0.3.0)

StuieT85 commented 4 years ago

I figured as much, I will just have to continue to do what I am doing at the moment which is create a function that converts a yearquarter back into a date, subtracts one year and then return it to a yearquarter, just need to remember to do it prior to presenting to bosses.

Honestly, thanks for creating a great package.

earowang commented 4 years ago

To make maintenance easier, we'll stick to the fiscal year convention.