Created
February 10, 2018 16:36
-
-
Save UniIsland/3ca40a9b2ee842bfd876a0e6354058f0 to your computer and use it in GitHub Desktop.
Calculate Moving Average with R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## calculating moving average | |
## x: data vector | |
## n: use how many samples | |
## s: 1 - with lag; 2 - symmetrically | |
f.ma <- function(x,n=5,s=2){filter(x,rep(1/n,n), sides=s)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment