sum_ignore_NA: Sum ignoring NAs

Description Usage Arguments Details Value Examples

View source: R/MiscFxns.R

Description

Will sum values returning NA only if all values are NA, otherise will ignore

Usage

1

Arguments

...

numbers or vectors to be summed. Must be type logical or numeric.

Details

this function will provide vectorized sums with NAs ignored unless only NAs are present

Value

a numeric vector of the same length as the arguments

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# ignores NA
sum_ignore_NA(2, 3, NA)
# returns NA if all values are NA
sum_ignore_NA(NA, NA, NA)

# returns vectorized sums

x <- c(1, 2, NA)
y <- c(1:3)
sum_xy <- sum_ignore_NA(x, y)
data.frame(x, y, sum_xy)

x <- c(1, 2, NA)
y <- c(1, 2, NA)
sum_xy <- sum_ignore_NA(x, y)
data.frame(x, y, sum_xy)

ledbettc/CIDAtools documentation built on Jan. 24, 2020, 3:56 p.m.