Displaying 1 result from an estimated 1 matches for "movavgx".
Did you mean:
movavg
2011 Jul 28
0
_: how to replace values in x by means in subgroups created in ...(not loops)
...-------------------------------------------------------------------
# next to try in looking for faster solutions mayby:
#require(sqldf)
# centered moving average of length 7
#set.seed(1)
#DF <- data.frame(x = rnorm(15, 1:15))
#s18 <- sqldf("select a.x x, avg(b.x) movavgx from DF a, DF b
# where a.row_names - b.row_names between -3 and 3
# group by a.row_names having count(*) = 7
# order by a.row_names+0",
# row.names = TRUE)
#r18 <- data.frame(x = DF[4:12,], movavgx = rowMeans(embed(DF$x, 7)))
#row.names(r18) <- NULL
#al...