Description Usage Arguments Details Value Author(s)
ma
1 |
x |
A numeric vector |
left_interval |
an integer value of the number of values to include in the average to the LEFT of a given position |
right_interval |
an integer value of the number of values to include in the average to the RIGHT of a given position |
na.rm |
Should be na values be ignored? |
The moving average of a set of values. This function calculates the moving average across an interval. The interval is no consistently large as the extreme left and right of the vector since the interval 'walks' off the end of the vector where there are no values. The effect is that if you have a left interval of 2 and right interval of 2. The returns 1st index in the vector is the mean(x[1:3]), the 2nd is mean(x[1:4]), the 3rd is mean(x[1:5]), the 4th is mean(x[2:6]), the 5th is mean(x[3:7]) and so on. At the right end of the vector the same occurs in the opposite direction. The alternative approach is to return NA for return indexes 1:2 because you cannot calculate the moving average with a left interval of 2 for those values; this mthod is not implemented.
A numeric vector
Thomas Rosendal
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.