process_uploaded_data: Turn an uploaded table into a ds/y forecasting series

View source: R/data_utils.R

process_uploaded_dataR Documentation

Turn an uploaded table into a ds/y forecasting series

Description

The Import tab's core transform: renames the user's chosen date/value columns to ds/y, aggregates individual-observation data into periods, and optionally normalizes by a population table to produce incidence rather than absolute counts.

Usage

process_uploaded_data(
  data,
  type = c("agg", "individual"),
  date_col,
  value_col = NULL,
  group_col = NULL,
  pop_df = NULL,
  pop_date_col = NULL,
  pop_value_col = NULL,
  pop_group_col = NULL,
  unit_divisor = 1,
  pop_multiplier = 1,
  date_agg = "day",
  pop_freq = "year"
)

Arguments

data

A data frame – the uploaded main dataset.

type

"agg" (each row is already one value per period) or "individual" (each row is a single event, counted per period).

date_col

Character scalar, the name of data's date column.

value_col

Character scalar, the name of data's value column (required when type = "agg", ignored for "individual").

group_col

Optional character scalar, a grouping column (e.g. District) to carry through untouched alongside ds/y.

pop_df

Optional population data frame for normalization.

pop_date_col, pop_value_col

Character scalars naming pop_df's key and value columns (required together with pop_df to normalize).

pop_group_col

Optional character scalar, pop_df's grouping column, if it has one.

unit_divisor, pop_multiplier

Numeric scaling applied to the population figure (e.g. unit_divisor = 100000 for per-100k).

date_agg

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

pop_freq

Whether pop_df's value is given "year"ly or "month"ly.

Value

A tibble with columns ds, y, and group_col if supplied.

Examples

df <- data.frame(when = as.Date("2024-01-01") + 0:9, count = 1:10)
process_uploaded_data(df, type = "agg", date_col = "when", value_col = "count")

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