rowmean: Compute column means of a matrix based on a grouping variable

Description Usage Arguments Value Author(s) Examples

View source: R/rowmean.R

Description

A utility that is equivalent to rowsum, but computes the mean instead of the sum of each subset of rows.

Usage

1

Arguments

x

A numeric matrix or matrix-like object.

group

A vector or factor specifying the group assignment for each row of x.

...

Further arguments to pass to rowsum, e.g., reorder.

Value

A numeric matrix with one row per level of group, where the value for each column contains the average value across the subset of rows corresponding that level.

Author(s)

Aaron Lun

Examples

1
2
3
x <- matrix(runif(100), ncol = 5)
group <- sample(1:8, 20, TRUE)
(xmean <- rowmean(x, group))

TSCAN documentation built on Nov. 8, 2020, 5:13 p.m.