
Label rolling year periods
add_rolling_years.RdThe function labels and categorizes dates based on the rolling period specified. The start year will always be Year 1 and the rolling period is defined by the start date and the number of periods to account for in a given rolling year. For example, if the start date is defined as Jan 1, 2021 and we would like to calculate a 12-month rolling period, the end date would be Dec 31, 2021.
Usage
add_rolling_years(
df,
start_date,
end_date,
date_col,
period = months(12, FALSE)
)Arguments
- df
tibbleA dataset containing at least one date column.- start_date
strStart date of Year 1. All years are classified in reference to this date.- end_date
strEnd date to filter to.- date_col
strThe name of the date column.- period
periodAlubridate::period()object. Defaults tomonths(12, FALSE).
Details
The function will filter data using the column specified by date_col up to
the end date specified.
Examples
if (FALSE) { # \dontrun{
raw_data <- get_all_polio_data()
afp_data <- add_rolling_years(raw_data$afp, "2021-01-01", "2024-05-02", "dateonset")
} # }