aggregate_by_date: Function to aggregate time series data by dates.

View source: R/aggregate_by_date.R

aggregate_by_dateR Documentation

Function to aggregate time series data by dates.

Description

aggregate_by_date does a similar job and has the same objectives of openair's timeAverage. However, it has been developed to perform on "longer" data which is often encountered.

Usage

aggregate_by_date(
  df,
  interval = "hour",
  by = NA,
  summary = "mean",
  threshold = 0,
  round = NA,
  pad = TRUE,
  determine_interval = TRUE,
  warn = TRUE,
  verbose = FALSE
)

Arguments

df

Input data frame to be aggregated. df must contain "date" and "value" variables. The "date" variable must be a POSIXct date class and the value must be a numeric or integer data type.

interval

What interval should the aggregation be? Default is "hour".

by

What variables should df be grouped by? Common groups are "site" and "variable".

summary

What summary function should be applied for the aggregation? Default is the mean. The options are:

  • mean

  • median

  • max

  • min

  • sum

  • count

  • sd

  • mode

  • data_capture

threshold

What data capture threshold is needed to create a valid aggregation. This is an value between 0 and 1. Zero would mean any number of values will be valid but 0.75 would mean 75 % of values are needed for a valid average.

round

Should the aggregations be rounded? Default is no but 3 would round to three decimal places.

pad

Should the time series be padded before aggregation? Almost always this will be TRUE but if you want to speed the function up and have done this previously, it can be set to FALSE.

determine_interval

Should the input time series be evaluate to find it's averaging period/interval. This is required for the correct calculation of threshold.

warn

Should the function return warnings in certain situations?

verbose

Should the function give messages?

Value

Tibble.

Author(s)

Stuart K. Grange

See Also

timeAverage, time_pad

Examples

## Not run: 

# Aggregate to hourly means
aggregate_by_date(data_air, "hour", by = c("site", "variable"))


## End(Not run)


skgrange/threadr documentation built on April 15, 2024, 9:35 p.m.