smooth <- function(
x,
old_weight
) {
backcast <-
x %>%
rev() %>%
purrr::reduce(~ old_weight * .x + (1 - old_weight) * .y) %>%
return()
x %>%
purrr::accumulate(~ old_weight * .x + (1 - old_weight) * .y, .init = backcast) %>%
magrittr::extract(-1) %>%
return()
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.