Learn R Programming

utile.tools (version 0.2.8)

calc_cumsum: Calculate cumulative summation of vector

Description

Calculate the cumulative summation of a numeric vector with revised NA handling compared to `base::cumsum()`.

Usage

calc_cumsum(x, na.fill = FALSE)

Value

A vector of the same length and type as x.

Arguments

x

A numeric.

na.fill

A logical. Impute forward for NA values.

Examples

Run this code
x <- 1:10
x[3:4] <- NA

# Calculate cumsum & replace NA values
calc_cumsum(x, na.fill = TRUE)

Run the code above in your browser using DataLab