sumNA: Modified sum of vector elements

Description Usage Arguments Value See Also Examples

View source: R/sumNA.R

Description

The function sumNA returns the sum of all the values in its arguments. Contrarily to sum, it returns NA instead of 0 when the input contains only missing values and missing values are removed.

Usage

1
sumNA(..., na.rm = FALSE)

Arguments

...

numeric or complex or logical vectors.

na.rm

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

Value

The sum. Returns NA if x contains only missing values and na.rm = TRUE.

See Also

sum.

Examples

1
2
3
4
5
6
7
8
x <- c(NA, NA)
sum(x)
sumNA(x)
sum(x, na.rm = TRUE)
sumNA(x, na.rm = TRUE) # here is the difference with 'sum()'

sum(c())
sumNA(c())

paulponcet/bazar documentation built on July 15, 2019, 5:28 a.m.