Skip to contents

Given any date from a ("epiweek") return the date of the first (floor_ functions) or final (ceiling_ functions) day of the epiweek, according to the given epidemiological week standard.

Usage

floor_epiweek(date, epiweek_standard)

ceiling_epiweek(date, epiweek_standard)

floor_isoweek(date)

floor_mmwr_epiweek(date)

ceiling_isoweek(date)

ceiling_mmwr_epiweek(date)

Arguments

date

A date.

epiweek_standard

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

Value

The date that starts or ends the epidemiological week, as a lubridate::date().

Examples

floor_isoweek(as.Date("2025-03-13")) # rounded to Monday
#> [1] "2025-03-10"
floor_isoweek(as.Date("2025-03-10")) # this is already Monday
#> [1] "2025-03-10"
ceiling_isoweek(as.Date("2025-03-13")) # rounded to Sunday
#> [1] "2025-03-16"
ceiling_isoweek(as.Date("2025-03-16")) # this is already Sunday
#> [1] "2025-03-16"
floor_mmwr_epiweek(as.Date("2025-03-13")) # rounded down to Sunday
#> [1] "2025-03-09"
floor_mmwr_epiweek(as.Date("2025-03-09")) # this is already Sunday
#> [1] "2025-03-09"
ceiling_mmwr_epiweek(as.Date("2025-03-13")) # rounded to Saturday
#> [1] "2025-03-15"
ceiling_mmwr_epiweek(as.Date("2025-03-15")) # this is already Saturday
#> [1] "2025-03-15"
floor_epiweek(as.Date("2025-03-13"), epiweek_standard = "iso")
#> [1] "2025-03-10"
ceiling_epiweek(as.Date("2025-03-13"), epiweek_standard = "USA")
#> [1] "2025-03-15"
ceiling_epiweek(as.Date("2025-03-13"), epiweek_standard = "mmwr")
#> [1] "2025-03-15"