SRrun3 | R Documentation |
Calculate the three-year moving average of a time series of data, by the specified grouping variables.
SRrun3(df, x, group, time, minfreq = 2)
df |
A data frame containing the data to be averaged. |
x |
A character scalar, naming the element of |
group |
A character scalar, naming the element of |
time |
A character scalar, naming the element of |
minfreq |
A numeric scalar, the minimum number of non-missing observations required to calculate an average, default 2. |
A data frame with one row per group and time, giving the raw observations (Y) and their corresponding three-year running mean (Y.3mn).
rawdat <- data.frame( Year = 1990 + c(0:5, 8:9, 2:3, 5:8), Type = rep(1:2, c(8, 6)), Y = c(1:12, 9, 7)*10 ) SRrun3(rawdat, "Y", "Type", "Year", minfreq=1) SRrun3(rawdat, "Y", "Type", "Year") SRrun3(rawdat, "Y", "Type", "Year", minfreq=3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.