This is a utility function mostly designed to calculate rolling quantile statistics. The function will try and fill in missing time gaps to get a full time sequence but return a data frame with the same number of rows supplied.
Usage
rollingQuantile(
mydata,
pollutant = "o3",
width = 8L,
type = "default",
data.thresh = 75,
align = c("centre", "center", "left", "right"),
probs = 0.5,
date.pad = FALSE,
...
)Arguments
- mydata
A data frame containing a
datefield.mydatamust contain adatefield inDateorPOSIXctformat. The input time series must be regular, e.g., hourly, daily.- pollutant
The name of a pollutant, e.g.,
pollutant = "o3".- width
The averaging period (rolling window width) to use, e.g.,
width = 8will generate 8-hour rolling mean values when hourly data are analysed.- type
Used for splitting the data further. Passed to
cutData().- data.thresh
The % data capture threshold. No values are calculated if data capture over the period of interest is less than this value. For example, with
width = 8anddata.thresh = 75at least 6 hours are required to calculate the mean, elseNAis returned.- align
Specifies how the moving window should be aligned.
"right"means that the previous hours (including the current) are averaged."left"means that the forward hours are averaged."centre"(or"center"- the default) centres the current hour in the window.- probs
Probability for quantile calculate. A number between 0 and 1. Can be more than length one e.g.
probs = c(0.05, 0.95).- date.pad
Should missing dates be padded? Default is
FALSE.- ...
Additional parameters passed to
cutData(). For use withtype.
Examples
# rolling 24-hour 0.05 and 0.95 quantile for ozone
mydata <- rollingQuantile(mydata,
pollutant = "o3", width = 24, data.thresh = 75, align = "right", probs = c(0.05, 0.95)
)
