Skip to contents

Adaptation of base::colSums() that, when all values in a column are NA, sets the sum to NA rather than zero as base::colSums() does. Calls base::colSums() internally.

Usage

col_sums(mx, na.rm = FALSE, dims = 1)

Arguments

mx

numeric matrix

na.rm

logical(1). TRUE if missing values (NA) should be ignored in the summation. If FALSE (default), even one missing value will result in NA for the entire column.

dims

See documentation for base::colSums()

Value

numeric vector whose length is number of columns of mx, whose values are the sums of each column of mx.