rowmean {TSCAN} | R Documentation

## Compute column means of a matrix based on a grouping variable

### Description

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

### Usage

    rowmean(x, group, ...)

### 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

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

[Package TSCAN version 1.28.0 Index]