movingFun(x, n, fun=mean, type='around', circular=FALSE, na.rm=FALSE)
type
is 'around', the other elements are before and after the focal element. Alternatively,true
, the data are considered to have a circular nature (e.g. months of the year), and the last elements in vector x
are used in the computation of the moving function of the first element(s) of the vector, and the fiTRUE
, NA
values should be ingored (by fun
)movingFun(1:12, 3, mean)
movingFun(1:12, 3, mean, 'to')
movingFun(1:12, 3, mean, 'from')
movingFun(1:12, 3, mean, circular=TRUE)
v <- c(0,1,2,3,3,3,3,4,4,4,5,5,6,7,7,8,9,NA)
movingFun(v, n=5)
movingFun(v, n=5, na.rm=TRUE)
Run the code above in your browser using DataLab