Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add season argument and refactor epi_calendar #34

Merged
merged 9 commits into from
Oct 17, 2024

Conversation

SofiaOtero
Copy link
Contributor

@SofiaOtero SofiaOtero commented Oct 15, 2024

Currently the ISO week daye system is not correctly implemented in epi_calender function.
%U: The week number (00–53) of the year (Sunday as the first day of the week).
%V: The ISO 8601 week number (01–53), where Monday is considered the first day of the week. The first week of the year is defined as the week containing the first Thursday of the year.
%Y: Year with century.
%G: The week-based year (see %V) as a decimal number.

Following function is changed to use the ISO numbering with "%V":

current_week <- as.integer(format(x = date, "%U")) ->
current_week <- as.integer(format(x = date, "%V"))

The year function does not use ISO either:
current_year <- format(date, "%Y")
meaning that fx date 2018-12-31 will be placed in season 2017/2018 instead of 2018/2019:

 ISOweek(as.Date("2018-12-31"))
[1] "2019-W01"
> epi_calendar(date = as.Date("2018-12-31"), start = 21, end = 20)
[1] "Year 2018"
[1] "Season 2017/2018"

Wil be changed to:

current_year <- as.integer(strftime(date, format = "%G"))

This approach correctly captures the ISO year, and ensures alignemnt with the ISO week date system.

Season has been added to the adseo function

  • the season can be given as season = c(start,end) which is the start and end week of the season.
  • the function then uses epi_calendar to calculate which season the observations belong to.
  • Seasons have to spand two years.

Summary now also shows which time interval the observations have.

  • Summary shows which seasons are included in the tsd. -> if the user did not select seasons then it will just state "Not defined".

This PR builds on following PR which needs to be merged before this PR is ready

Checklist

  • The PR passes all local unit tests
  • I have documented any new features introduced
  • If the PR adds a new feature, please add an entry in NEWS.md
  • A reviewer is assigned to this PR

@SofiaOtero SofiaOtero marked this pull request as ready for review October 16, 2024 10:32
@SofiaOtero SofiaOtero added enhancement New feature or request refactor improve code without changing functionality labels Oct 16, 2024
R/aedseo.R Show resolved Hide resolved
R/aedseo.R Outdated Show resolved Hide resolved
R/aedseo.R Outdated Show resolved Hide resolved
R/aedseo.R Outdated Show resolved Hide resolved
R/epi_calendar.R Outdated Show resolved Hide resolved
R/epi_calendar.R Show resolved Hide resolved
R/summary.R Outdated Show resolved Hide resolved
@SofiaOtero SofiaOtero merged commit 9d2316c into master Oct 17, 2024
13 checks passed
@SofiaOtero SofiaOtero deleted the add_season_argument branch October 17, 2024 09:11
@SofiaOtero SofiaOtero self-assigned this Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactor improve code without changing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants