colScale: Column Centering and Scaling

Description Usage Arguments Value Examples

Description

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

Usage

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

Arguments

x

numeric matrix

center

Should the columns be centered

scale

Should the columns 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 = colScale(x)
all(abs(colMeans(cx)) < 1e-8)
all(abs(matrixStats::colSds(cx) - 1) < 1e-8)

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