rowSums_na: rowSums with na.rm = TRUE except for when all cols = NAs...

Description Usage Arguments Examples

View source: R/rowSums_na.R

Description

rowSums with na.rm = TRUE except for when all cols = NAs equivalent to sum functionality in SAS (I think)

Usage

1
rowSums_na(x, dims = 1)

Arguments

x

an array of two or more dimensions, containing numeric, complex, integer or logical values, or a numeric data frame. For .colSums() etc, a numeric, integer or logical matrix (or vector of length m * n).

dims

integer: Which dimensions are regarded as 'rows' or 'columns' to sum over. For row, the sum or mean is over dimensions dims+1, ...; for col it is over dimensions 1:dims.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
x <- cbind(x1 = c(NA,2:5), x2 = c(NA,7:9,NA))
rowSums_na(x)
## as opposed to
rowSums(x)

x <- array(2, rep(3, 3))
x[1,,]<-NA
x[3,3,3]<-NA
rowSums_na(x)
## as opposed to
rowSums(x)

josiahpjking/jkr documentation built on Sept. 7, 2020, 3:54 a.m.