Open ffinger opened 4 years ago
@S-Balandine @PaulC91 @patrickbarks
Hi @ffinger,
Thank you for pointing this out. The way {aweek} works is that it looks for the first week that contains at least four days of the new year, otherwise, it is the last week of the previous year.
I'm afraid that I do not have much time to implement an alternative definition at the moment (I'm currently moving jobs and do this voluntarily now). Can you point me to some documentation that defines these different week definitions?
Hi @zkamvar,
yes, I am aware that you do this voluntarily now, I mainly wanted to document the issue and start a discussion about the possible solutions. All the better if you have time to start implement things, but feel free to say no.
The isoweek definition (week 1 is the week of the first Thursday in a year) is equivalent to yours (first week that contains 4 days of the new year. For the CDC epiweek it's the same.
The other definitions I was talking about are unfortunately not standardized and depend on the country, the implementing agency or even the dataset. This is why I would go with a fully flexible framework if possible, keeping the current definition as the standard.
I would suggest to implement two alternative ways of defining the first week:
What do you think?
This package conveniently handles week to date and date to week conversions with varying definitions of the first day in each week.
In epidemiology we are also confronted with varying definitions of week 1 in a year. The ISO norm says: "week 01 is the week with the Gregorian year's first Thursday in it", the week before being week 52 or 53 of the previous year. https://en.wikipedia.org/wiki/ISO_week_date#First_week
There is however situations in which week 1 is defined as the week containing 1st January, which is not always the same as above. Other definitions are also possible, e.g. the week containing the first Monday, Tuesday, ... Sunday of a year.
It would be great to add an option to choose which of these definitions should be used, with a default to the definition used by ISO.