resample_time: Resample time series to a coarser period

View source: R/resample_time.R

resample_timeR Documentation

Resample time series to a coarser period

Description

Aggregates time series data to a specified period (hour, day, or month) using a chosen summary statistic. The function requires a time column.

Usage

resample_time(data, cols = NULL, date_col = NULL,
              period = "hour", fun = "mean", na.rm = TRUE,
              verbose = FALSE)

Arguments

data

A data frame with a time column.

cols

Column indices or names to aggregate.

date_col

Time column index or name.

period

Target period: "hour", "day", or "month".

fun

Aggregation function: "mean", "sum", "min", "max", "median", or "sd".

na.rm

Logical; whether to remove NA values before aggregation.

verbose

Logical; if TRUE, prints progress message.

Value

A data frame with aggregated time series.

Examples

resample_time(data[1:500, c(1, 4, 17:19)], cols = 3:5, date_col = 1, period = "hour", fun = "mean")

dataprep documentation built on Oct. 1, 2026, 5:07 p.m.