colsweep: Sweep out Matrix Summaries Based on Grouping

colsweepR Documentation

Sweep out Matrix Summaries Based on Grouping

Description

Apply the equivalent of sweep to either columns or rows of a matrix, using a grouping variable.

Usage

## S4 method for signature 'ANY'
colsweep(x, STATS, FUN = "-", group = NULL, ...)

## S4 method for signature 'matter_mat'
colsweep(x, STATS, FUN = "-", group = NULL, ...)

## S4 method for signature 'sparse_mat'
colsweep(x, STATS, FUN = "-", group = NULL, ...)

## S4 method for signature 'ANY'
rowsweep(x, STATS, FUN = "-", group = NULL, ...)

## S4 method for signature 'matter_mat'
rowsweep(x, STATS, FUN = "-", group = NULL, ...)

## S4 method for signature 'sparse_mat'
rowsweep(x, STATS, FUN = "-", group = NULL, ...)

Arguments

x

A matrix-like object.

STATS

The summary statistic to be swept out, with length equal to the number of columns of 'x' (for colsweep()) or the number of the rows of 'x' (for rowsweep()). If a grouping variable is given, then this must be a matrix with number of columns equal to the number of groups.

FUN

The function to be used to carry out the sweep.

group

A vector or factor giving the groupings with length equal to the number of rows of 'x' (for colsweep()) or the number of the columns of 'x' (for rowsweep()).

...

Ignored.

Details

See sweep for details.

Value

A matrix-like object (usually of the same class as x) with the statistics swept out.

Author(s)

Kylie A. Bemis

See Also

sweep

Examples

set.seed(1)

x <- matrix(1:100, nrow=10, ncol=10)

colsweep(x, colStats(x, "mean"))

kuwisdelu/matter documentation built on Oct. 19, 2024, 10:31 a.m.