accumulate_for_days: Delayed accumulation

View source: R/fct_accumulate_for_days.R

accumulate_for_daysR Documentation

Delayed accumulation

Description

given a vector accumulate the sum supposing each elements count for a given period of time.

Usage

accumulate_for_days(x, n)

Arguments

x

vector to accumulate

n

number of "times" each element count in the sum

Value

a vector of length length(x) + n -1

Examples


accumulate_for_days(c(1, 2, 3), 2) # c(1, 3, 5, 3)
accumulate_for_days(c(1, 2, 3), 3) # c(1, 3, 6, 5, 3)
accumulate_for_days(c(NA, 2, 3), 3) # c(0, 2, 5, 5, 3)

UBESP-DCTV/covid19ita documentation built on May 15, 2024, 10:40 a.m.