averageAcrossRows: Averages rows together

View source: R/util.R

averageAcrossRowsR Documentation

Averages rows together

Description

Rearranges and averages rows according to by.

Usage

averageAcrossRows(data, by = labels, func = mean, ...)

Arguments

data

the matrix whose rows should be averaged.

by

an integer or vector by which to average and/or rearrange rows.

func

the function to apply to the result. Default: mean.

...

additional arguments to be passed to aggregate().

Value

Returns a vector or matrix of averaged rows.

Author(s)

Rehrauer, Hubert

Schmid, Peter

Examples

m1 = matrix(1:20,5)
averageRows(m1,c(1,1,2,2,3))

uzh/ezRun documentation built on June 14, 2025, 1:29 p.m.