SMA.Rd
SMA
creates a streaming algorithm that can be used to
keep track of the mean of the previous k datapoints
An R6Class
generator object
new()
Creates a new SMA
streamer object.
SMA$new(x = NULL, window = NULL)
mean <- SMA$new(window = 5)
update()
Resets the SMA
streamer object.
mean <- SMA$new(c(1, 2, 3, 4, 5), window = 3)
mean$value
#> [1] 4
#> [1] 4
## ------------------------------------------------
## Method `SMA$new`
## ------------------------------------------------
mean <- SMA$new(window = 5)
## ------------------------------------------------
## Method `SMA$update`
## ------------------------------------------------
mean <- SMA$new(c(1, 2, 3), window = 3)
mean$update(c(4, 5))