sum0: Sum of Vector Elements with alternative empty-set definition

Description Usage Arguments Value See Also Examples

View source: R/sum0.R

Description

Sum of Vector Elements with alternative empty-set definition

Usage

1
sum0(x, na.rm = TRUE)

Arguments

x

numeric, complex or logical vector

na.rm

logical. Should missing values (including NaN) be removed?

Value

scalar sum of all values in x. Different to sum, the sum of an empty set is undefined (see example). This is helpful for aggregating count data across observations that are nested in groups and for some groups all observations are missing

See Also

sum

Examples

1
2
3
4
 x <- c(NA,NA,NA)
 sum(x,na.rm=TRUE)
 sum0(x,na.rm=TRUE)
 

sumtxt/datatools documentation built on Jan. 3, 2021, 1:39 a.m.