Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upquarter() function bug #682
Comments
|
I believe there is still a bug in the function for
I'm running:
With:
|
|
Indeed. Looks like the logic of quarter is plain bogus. Will have to carefully dig into it. |
|
It's probably worth documenting the expected behavior of the function. FWIW, Wikipedia says:
That seems to be the expected behavior of most of the tests and what is described in the bug report above. However, one of the tests from the commit closing this issue seems to violate that expectation. I don't know what is right, but following that convention, I believe the test should be updated to:
The following function passes all other tests (and the modified one above):
Happy to submit a PR if this is the expected behavior and solves the issue. Here's the full diff for reference:
|
|
@borgmaan Was there a resolution to this? |
|
It appears the bug still exists for fiscal years starting in month 4 (or 3 or 2). I would expect that a FY starting April would show 2019-01-10 as FY 2018 Qtr 4 or 2018.4 result for the quarter() function when with_year=TRUE. Currently |
|
While this doesn't conform to the "Fiscal Quarters" definition covered by @borgmaan, it does address the incorrect year for fiscal_start=4 outlined by @mielniczuk to produce an output of 2018.4 (Fiscal Years that START in April and end in Mach of the following year).
|
|
This issue slipped my radar as I forgot to re-open it back in 2018. It's fixed in the master and will be released to CRAN this week. |
First, I would like to thank the authors @hadley @jiho @mmparker @zeehio @garrettgman for this package, and in particular the development of the
quarter()function which does a great job of reducing the amount of code needed to generate FY and Quarter values. I would like to point out that there currently appears to be a bug in the way thequarter()function appends a fiscal year with_year.Original example
x <- ymd(c("2012-03-26", "2012-05-04", "2012-09-23", "2012-12-31"))quarter(x, with_year = TRUE, fiscal_start = 11)[1] 2012.2 2012.3 2012.4 2013.1This works fine with the december 2012 date reported as fiscal year 2013 Q1.
However if I move the fiscal start to April, we don't see similar treatment for fiscal year of the first date -- which should be 2011 Q4 based on this formatting.
quarter(x, with_year = TRUE, fiscal_start = 4)[1]2012.42012.1 2012.2 2012.3