NA and Inf values in the y will be ignored automatically.

movmean(y, halfwin = 1L, SG_style = FALSE, w = NULL)

movmean2(y, win_left = 1L, win_right = 0L, w = NULL)

movmean_2d(mat, win_left = 3L, win_right = 0L)

Arguments

y

A numeric vector.

halfwin

Integer, half of moving window size

SG_style

If true, head and tail values will be in the style of SG (more weights on the center point), else traditional moving mean style.

w

Corresponding weights of y, with the same length.

win_left, win_right

windows size in the left and right

mat

numeric matrix

Examples

x <- 1:100
x[50] <- NA; x[80] <- Inf
s1 <- movmean(x, 2, SG_style = TRUE)
s2 <- movmean(x, 2, SG_style = FALSE)
movmean2(c(4, 8, 6, -1, -2, -3, -1), 2, 0)
#> [1]  4.000000  6.000000  6.000000  4.333333  1.000000 -2.000000 -2.000000
movmean2(c(4, 8, NA, -1, -2, Inf, -1), 2, 0)
#> [1]  4.0  6.0  6.0  3.5 -1.5 -1.5 -1.5