Skip to contents

Scale the rows of a matrix.

Usage

scale_rows(m)

Arguments

m

A numeric matrix

Value

A matrix whose rows have been scaled.

Examples

scale_rows(diag(4))
#>      [,1] [,2] [,3] [,4]
#> [1,]  1.5 -0.5 -0.5 -0.5
#> [2,] -0.5  1.5 -0.5 -0.5
#> [3,] -0.5 -0.5  1.5 -0.5
#> [4,] -0.5 -0.5 -0.5  1.5
#> attr(,"scaled:center")
#> [1] 0.25 0.25 0.25 0.25
#> attr(,"scaled:scale")
#> [1] 0.5 0.5 0.5 0.5