rowScale: Row Centering and Scaling

Description Usage Arguments Value Examples

Description

This function is a fast way to scale rows of a matrix

Usage

1
2
rowScale(x, center = TRUE, scale = TRUE, add_attr = TRUE, rows = NULL,
  cols = NULL, na.rm = TRUE, ...)

Arguments

x

numeric matrix

center

Should the rows be centered

scale

Should the rows be scaled

add_attr

Add the center/scale attributes

rows

A vector indicating subset of rows to operate over. If NULL, no subsetting is done.

cols

A vector indicating subset of columns to operate over. If NULL, no subsetting is done.

na.rm

If TRUE, missing values are removed first, otherwise not.

...

Arguments to pass to rowSds

Value

Matrix of centered/scaled values

Examples

1
2
3
4
x = matrix(rnorm(10*1000, mean = 4, sd = 5), ncol = 10)
cx = rowScale(x)
all(abs(rowMeans(cx)) < 1e-8)
all(abs(matrixStats::rowSds(cx) - 1) < 1e-8)

muschellij2/msseg documentation built on May 23, 2019, 9:53 a.m.