Learn R Programming

nomisdata (version 0.1.1)

aggregate_time: Aggregate Time Series

Description

Aggregates data over time periods.

Usage

aggregate_time(
  data,
  period = c("year", "quarter", "month"),
  value_col = "OBS_VALUE",
  fun = mean
)

Value

A tibble with PERIOD column and aggregated values.

Arguments

data

Data frame with DATE column

period

Aggregation period: "year", "quarter", "month"

value_col

Column containing values to aggregate

fun

Aggregation function (default: mean)

Examples

Run this code
data(jsa_sample)
# \donttest{
if ("DATE" %in% names(jsa_sample)) {
  yearly_data <- aggregate_time(jsa_sample, "year", "OBS_VALUE")
}
# }

Run the code above in your browser using DataLab