averageColumns: Averages columns together

View source: R/util.R

averageColumnsR Documentation

Averages columns together

Description

Rearranges and averages columns according to by.

Usage

averageColumns(x, by = NULL, func = function(x) {
    mean(x, na.rm = TRUE)
})

Arguments

x

the matrix whose columns should be averaged.

by

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

func

the function to apply to the result. Default: mean with removing NAs.

Value

Returns a vector or matrix of averaged columns.

Author(s)

Rehrauer, Hubert

Schmid, Peter

Examples

m1 = matrix(1:20,5)
rownames(m1) = 1:5
m2 = averageColumns(m1,1)
m3 = averageColumns(m1,c(4,2,3,1))
m4 = averageColumns(m1,c(1,1,2,2))

uzh/ezRun documentation built on April 24, 2024, 4:01 p.m.