Learn R Programming

dataprep (version 0.1.8)

resample_time: 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)

Value

A data frame with aggregated time series.

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.

Examples

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

Run the code above in your browser using DataLab