rowsum: Compute column/row sums of a matrix-like object, for groups...

rowsumR Documentation

Compute column/row sums of a matrix-like object, for groups of rows/columns

Description

rowsum() computes column sums across rows of a numeric matrix-like object for each level of a grouping variable.

colsum() computes row sums across columns of a numeric matrix-like object for each level of a grouping variable.

NOTE: This man page is for the rowsum and colsum S4 generic functions defined in the S4Arrays package. See ?base::rowsum for the default rowsum() method (defined in the base package). Bioconductor packages can define specific methods for objects (typically matrix-like) not supported by the default methods.

Usage

rowsum(x, group, reorder=TRUE, ...)

colsum(x, group, reorder=TRUE, ...)

Arguments

x

A numeric matrix-like object.

group, reorder, ...

See ?base::rowsum for a description of these arguments.

Value

See ?base::rowsum for the value returned by the default method.

The default colsum() method simply does t(rowsum(t(x), group, reorder=reorder, ...)).

Specific methods defined in Bioconductor packages should behave as consistently as possible with the default methods.

See Also

  • base::rowsum for the default rowsum method.

  • showMethods for displaying a summary of the methods defined for a given generic function.

  • selectMethod for getting the definition of a specific method.

  • rowsum,DelayedMatrix-method in the DelayedArray package for an example of a specific rowsum method (defined for DelayedMatrix objects).

Examples

rowsum  # note the dispatch on the 'x' arg only
showMethods("rowsum")
selectMethod("rowsum", "ANY")     # the default rowsum() method

colsum  # note the dispatch on the 'x' arg only
showMethods("colsum")
selectMethod("colsum", "ANY")     # the default colsum() method
selectMethod("colsum", "matrix")  # colsum() method for ordinary matrices

Bioconductor/S4Arrays documentation built on Oct. 30, 2024, 12:13 p.m.