I have to calculate Simple Moving Averages on some data with this formula in R:
Does anybody know how to do that?
Are you looking for something like that?
Func <- function(xt){
St <- 1/10*sum(sapply(0:9, function(z) xt-z))
return(St)
}
And the output for two example of Xt:
> Func(10)
5.5
> Func(15)
10.5