
Time Aggregation of time series
timeAggregation.RdWARNING: This function is now deprecated and it will be removed in the future.
Usage
timeAggregation(
mydata,
avg.time,
statistics = "mean",
percentile = NA,
name.variable = NULL,
variables = "all",
name.value = NULL,
name.time = "time",
name.station = NULL,
stations = "all",
val.check = FALSE,
...
)Arguments
- mydata
A
data.frameordata.tablecontaining a time series with time and value columns. If more than one variable is present in the data set, the table must be in "long format."- avg.time
A character vector indicating time step on which compute the statistics. It can be one of the following: "min", "hour", "day", "month" or "year". No default.
- statistics
A character vector indicating the statistics to apply when aggregating data. It can be one of "mean", "min", "max", "sum", "percentile". Default = "mean".
- percentile
A numeric indicating the percentile used when
statistics = "percentile". No default.- name.variable
A character vector indicating the name of the column with the variables in
mydata.- variables
A character vector indicating the names of variables to be select in the
name.variablecolumn. Default is "all", i.e. if only one variable is present it can be omitted.- name.value
A character vector indicating the name of the column with the values to be aggregated.
- name.time
A character vector indicating the name of the column with date/time values.
- name.station
A character vector indicating the name of the column with the stations code.
- stations
A character vector indicating the names of stations to be computed. The output will be grouped by the selected stations. Default = "all".
- val.check
If TRUE set to NA if result is not valid data according to Directive 2008/50/CE. Default is FALSE.
- ...
Options passed to the statistics function defined in
statistic. For example:na.rm = TRUE.
Details
Function to aggregate time series according to different statistics, selecting the time step for grouping.
The function computes time aggregation of a time series according to the statistics defined in the arguments. The input data can be a simple time series or a more complex data set in long format.
Examples
if (FALSE) { # \dontrun{
# mydata is a `data.frame` with columns "time" and "no2". Time delta t is 1 hour.
head(mydata)
# time no2
# 1 2015-01-01 03:00:00 30.43931
# 2 2015-01-01 04:00:00 27.60286
# 3 2015-01-01 05:00:00 31.34683
# 4 2015-01-01 06:00:00 35.82242
# 5 2015-01-01 07:00:00 49.91434
# 6 2015-01-01 08:00:00 64.80641
# Compute daily averages:
dailyAvg <- timeAggregation(mydata, avg.time = "day", name.time = "time",
name.value = "no2", statistics = "mean")
# mydata is a `data.table` in long format with many concentrations of many
# pollutants: each row has one concentration value in the "conc" column;
# the pollutant is specified in the "pollutants" column:
dailyValues <- timeAggregation(mydata, variables = "PM10", name.variable = "pollutants",
name.value = "conc", na.rm = TRUE)
} # }