WMA.RdWMA creates a streaming algorithm that can be used to
keep track of the weighted mean of incoming values.
In an n-day WMA the latest day has weight n, the second latest n-1, etc., down to one.
An R6Class generator object
new()Creates a new WMA streamer object.
WMA$new(x = NULL)weighted_mean <- WMA$new()update()Resets the WMA streamer object.
mean <- WMA$new(c(1, 2))
mean$update(c(3, 4))
mean$value
#> [1] 7.5
#> [1] 7.5
## ------------------------------------------------
## Method `WMA$new`
## ------------------------------------------------
weighted_mean <- WMA$new()
## ------------------------------------------------
## Method `WMA$update`
## ------------------------------------------------
weighted_mean <- WMA$new()
weighted_mean$update(c(1, 2))