Learn R Programming

EEAaq (version 1.0.2)

EEAaq_time_aggregate: Time aggregation of an EEAaq_df class object.

Description

EEAaq_time_aggregate compute a time aggregation of an EEAaq_df or EEAaq_df_sfc class object, based on the specified frequency and the aggregation functions aggr_fun.

Usage

EEAaq_time_aggregate(
  data = NULL,
  frequency = "monthly",
  aggr_fun = c("mean", "min", "max")
)

Value

A EEAaq_taggr_df or a EEAaq_taggr_df_sfc class object, which is a tibble containing the required time aggregation.

Arguments

data

an EEAaq_df or EEAaq_df_sfc class object, which is the output of the EEAaq_get_data function.

frequency

vector containing the time frequency for which to aggregate the data object. Admissible values are 'yearly', 'monthly', 'weekly', 'daily' 'hourly'.

aggr_fun

character vector containing one or more agregation functions. Admissible values are 'mean', 'median', 'min', 'max', 'sd', 'var', 'quantile_pp' (where pp is a number in the range [0,1], representing the required percentile).

Examples

Run this code
# \donttest{
### Filter all the stations installed in the city (LAU) of Milano (Italy)
IDstations <- EEAaq_get_stations(byStation = FALSE, complete = FALSE)
`%>%` <- dplyr::`%>%`
IDstations <- IDstations %>%
                dplyr::filter(LAU_NAME == "Milano") %>%
                dplyr::pull(AirQualityStationEoICode) %>%
                unique()
### Download NO2 measurement for the city of Milano from January 1st to December 31st, 2023
data <- EEAaq_get_data(IDstations = IDstations, pollutants = "NO2",
                       from = "2023-01-01", to = "2023-01-31", verbose = TRUE)

### Monthly aggregation: compute station-specific monthly minimum,
## average, and maximum NO2 concentrations
t_aggr <- EEAaq_time_aggregate(data = data, frequency = "monthly",
                               aggr_fun = c("mean", "min", "max"))

### Weekly aggregation: compute station-specific monthly average
##and standard deviation concentrations
t_aggr <- EEAaq_time_aggregate(data = data, frequency = "weekly",
                               aggr_fun = c("mean", "sd"))
# }

Run the code above in your browser using DataLab