cumsumNA: Computes the cummulative sum of a vector without propagating...

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/cumsumNA.R

Description

Computes the cummulative sum of a vector without propagating NAs

Usage

1

Arguments

x

An integer or double vector

Details

If x is integer, then integer addition is used. Otherwise, floating point (double) addition is used. Elements in x that were NA will continue to be NA, but the NA will not be propagated.

Value

The vector of cumulative sums.

Author(s)

Landon Sego

See Also

cumsum

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# Compare to cumsum()
x <- as.integer(c(5, 2, 7, 9, 0, -1))
cumsum(x)
cumsumNA(x)

# Now with missing values
x[c(2,4)] <- NA
print(x)
cumsum(x)
cumsumNA(x)

pnnl/Smisc documentation built on Oct. 18, 2020, 6:18 p.m.