moving | R Documentation |
Calculate moving average.
moving(x, k = 5, ends = NA)
x |
a numeric vector. |
k |
how many values are evaluated in moving average. |
ends |
how the ends should be treated. |
Alternative end
treatments are:
NA | use NA values |
FALSE | truncate, so output is shorter than x |
TRUE | evaluate moving average on ends, even if the neighbors are all on one side |
Vector of same length as x
, containing weighted averages.
If k
is an even number, a weighted average is used with half weights
on each end.
This function is mainly useful if the ends have flat trends, e.g. a diagonal line will have bent ends...
runmean
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.