| rollingMax | R Documentation |
The function computes the rolling maximum value along a time series.
rollingMax(mydata, length = 24)
mydata |
A numeric vector of data values |
length |
An integer specifying the window size (number of observations) to consider. Must be at least 3 (default = 24). |
It calculates the maximum over consecutive elements centered within a specified window.
For each index i, it considers a window of length points centered around i.
When length is odd, the center falls exactly on i and the window extends
equally to both sides.
When length is even, the window extends one less point to the left than to
the right and the rolling max is not exactly centered.
Values near the start of the series use windows with fewer than length
data points if there are not enough preceding elements to form a full window.
Similarly for values at the end.
A numeric vector containing rolling maximum values, with same
dimensions as mydata.
# Compute rolling max over a 24-hour period on hourly time series data
data(stMeteo)
ws_24h <- rollingMax(mydata = stMeteo$ws, length = 24)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.