Skip to contents

Function to convert an epidemiological week and year ("epiweek" and "epiyear") pair to a date in a safe way.

Usage

epiweek_to_date(epiweek, epiyear, day_of_week = 1, epiweek_standard = "MMWR")

Arguments

epiweek

Epidemiological week, as an integer (e.g. 46). Must be between 1 and the number of weeks in epiyear, as determined by epiyear_n_weeks().

epiyear

Epidemiological year, as an integer (e.g. 2022).

day_of_week

day of the epiweek whose date should be returned, as a 1-indexed integer. 1 is the first date in the epiweek and 7 the last. Default 1.

epiweek_standard

One of "MMWR" or "USA" (USA MMWR epiweek, starts on Sunday) and "ISO" (ISO week, starts on Monday). Not case-sensitive. Must be a single value. Default "MMWR".

Value

The date, as a lubridate::date object

Details

By default returns the first date of the epiweek, but can return any date in the epiweek. Two standard definitions of epidemiological weeks and years are supported: USA CDC / MMWR and ISO.

Examples


epiweek_to_date(5, 2025)
#> [1] "2025-01-26"

epiweek_to_date(5, 2025, day_of_week = 7)
#> [1] "2025-02-01"

epiweek_to_date(5, 2025, day_of_week = 7, epiweek_standard = "ISO")
#> [1] "2025-02-02"