Continuous Epidemiological Week Indexing for Time-Series Analysis

Provides a simple algorithm to generate a continuous epidemiological week index from date variables in a data frame. Weeks are computed as sequential 7-day intervals aligned to Mondays, starting from the earliest observed date or from a user-supplied start date. They do not reset at calendar year boundaries and are not ISO 8601 nor MMWR calendar weeks. Missing or non-convertible dates are returned as NA instead of stopping the computation. The approach is intended for epidemiological modeling and time-series analysis where temporal continuity is required.


CRAN downloads CRAN status

cepiweek

Description

cepiweek adds a continuous epidemiological week index to a data frame, based on a date variable.

Important

The weeks generated by cepiweek are continuous indexed weeks. They are not ISO 8601 nor MMWR calendar weeks. Weeks are 7-day intervals aligned on Mondays, counted from the earliest observed date (or from a start date), and they do not reset at calendar year boundaries.

They are intended for time-series analysis and epidemiological modeling.

Installation

# Official method (CRAN)
install.packages("cepiweek")

# From GitHub, method 1
# install.packages("devtools")
devtools::install_github("DanielDegina/cepiweek")

# From GitHub, method 2
# install.packages("remotes")
remotes::install_github("DanielDegina/cepiweek")

# Method 3: download the ZIP file, extract it, then in R:
devtools::install("path/to/cepiweek")   # directory where you placed the package

Usage

library(cepiweek)

k = data.frame(
  num  = 1:4,
  date = c("15-01-2024", "12/02/2025", NA, "2026-08-01")
)

# dmy / ymd dates (default); missing or non-convertible dates give NA
cepiweek(k, col_date = "date")

# American format (month-day-year)
cepiweek(k, col_date = "date", format = "mdy")

# Same origin for several columns: fix the start date
cepiweek(k, col_date = "date", start = "2024-01-01")

# Silence the warning about non-convertible dates
cepiweek(k, col_date = "date", quiet = TRUE)

The date column can be of class Date, POSIXct or character. Missing values, empty strings, "NA" and dates that cannot be converted are returned as NA.

License

This package is licensed under the MIT License. See LICENSE for details.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("cepiweek")

0.2.0 by Daniel Degina, 11 hours ago


https://github.com/DanielDegina/cepiweek


Report a bug at https://github.com/DanielDegina/cepiweek/issues


Browse source code at https://github.com/cran/cepiweek


Authors: Daniel Degina [aut, cre] , Joel Mbuyi [ctb]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports lubridate

Suggests testthat


See at CRAN