R/adstock.R

Defines functions adstock

Documented in adstock

#' Calculate adstock (decay)
#'
#' @param x Numeric vector to be passed through.
#' @param rate Decay rate to be applied to `x`
#' @export
adstock <- function(x, rate = 0){
  x %>%
    stats::filter(filter = rate, method = "recursive") %>%
    as.numeric() %>% return()
}
martinctc/tstoolbox documentation built on Nov. 20, 2024, 3:55 p.m.