This function returns a (by default) seven-day moving average of the variable passed in. Make sure the data is pre-sorted by date, and grouped by the appropriate grouping. The data should have no gaps in time.

ma(x, n = 7)

## Arguments

x

The variable to calculate the moving average of.

n

The number of lags to cover in the moving average.

## Examples


ma(1:9)
#> [1] NA NA NA NA NA NA  4  5  6