count_duplicate_periods: Count how many rows share a period

View source: R/aggregate_period.R

count_duplicate_periodsR Documentation

Count how many rows share a period

Description

Used to tell the user what collapse_to_period() would do, before doing it. With group_col supplied, rows only count as duplicates if they share both a period and a group – two different districts on the same date are not a collision.

Usage

count_duplicate_periods(df, date_agg = "day", group_col = NULL)

Arguments

df

A data frame with a ds (date-like) column.

date_agg

Aggregation frequency: one of "hour", "day", "week", "month", "quarter", "year".

group_col

Optional character scalar, a grouping column.

Value

A single integer: how many rows would be removed by collapsing (0 if none).

Examples

df <- data.frame(ds = as.Date(c("2024-01-01", "2024-01-02")), y = c(3, 5))
count_duplicate_periods(df, date_agg = "month")

forecastsuite documentation built on Oct. 18, 2026, 5:08 p.m.