rowscale.matrix: Scale a matrix by row

Description Usage Arguments Value Author(s) See Also Examples

View source: R/rowscale.R

Description

Scaling a matrix by row can be slightly slower due to a transposing step.

Usage

1
2
## S3 method for class 'matrix'
rowscale(x, center = TRUE, scale = TRUE)

Arguments

x

An matrix

center

Logical, passed to scale. to TRUE

scale

Logical, passed to scale. TRUE

Value

A matrix with each row scaled.

Author(s)

Jitao David Zhang <jitao_david.zhang@roche.com>

See Also

scale

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
mat <- matrix(rnorm(20), nrow=4)
rs.mat <- rowscale(mat)

print(mat)
print(rs.mat)
rowMeans(rs.mat)
apply(rs.mat, 1L, sd)

rowscale(mat, center=FALSE, scale=FALSE) ## equal to mat
rowscale(mat, center=TRUE, scale=FALSE)
rowscale(mat, center=FALSE, scale=TRUE)

ribiosUtils documentation built on March 13, 2020, 2:54 a.m.