plus Returns the sum of all values provided as arguments but ensures NA + NA = NA.

plus(x, na.rm = F)

Arguments

x

numeric vector.

na.rm

logical. Should missing values be removed?

Value

The sum of x

Details

This function is the same as sum() but if na.rm is FALSE and all input values are NA, it will return NA instead of 0.

Examples

plus(1:10)
#> [1] 55
plus(c(NA, NA))
#> [1] NA
plus(c(NA, NA), na.rm = T)
#> [1] NA