xsum_rowsums() and xsum_colsums() are exact versions of rowSums()
and colSums(): every row or column sum is the correctly rounded exact
sum. xsum_by() is an exact version of rowsum(): the rows of x are
summed within each group, and the result has one row per group, sorted.
Usage
xsum_rowsums(x, na.rm = FALSE)
xsum_colsums(x, na.rm = FALSE)
xsum_by(x, group, na.rm = FALSE)Arguments
- x
A numeric or logical matrix, or a data frame of numeric or logical columns. For
xsum_by(), also a vector.- na.rm
Remove
NAandNaNvalues before summing?- group
A vector with one value per row of
x(per element, for a vector).NAis a group of its own, sorted last, as inrowsum().
Value
xsum_rowsums() and xsum_colsums() return a double vector named
by the row or column names. xsum_by() returns a double matrix with one
row per group (named by the group) and one column per column of x.
Details
Special values follow the table in xsum(), cell by cell. Row sums are
computed a block of rows at a time, so the extra memory they need does not
grow with the number of rows.