Skip to contents

Normalize rows or columns by its standard deviation.

Usage

normalize(x, normalize = 0, ...)

Arguments

x

matrix

normalize

A numeric value indicating along what direction (rows, columns) to normalize by standard deviations. 0 = none, 1= rows, 2 = columns (default is 0).

...

Not evaluated.

Value

Not yet defined TODO!

Examples

x <- matrix(sample(1:5, 20, rep = TRUE), 4)
normalize(x, 1) # normalizing rows
#>          [,1]     [,2]     [,3]     [,4]      [,5]
#> [1,] 2.449490 3.265986 2.449490 3.265986 0.8164966
#> [2,] 3.651484 3.651484 4.564355 1.825742 3.6514837
#> [3,] 5.976143 5.976143 4.780914 3.585686 4.7809144
#> [4,] 1.025978 2.564946 2.564946 2.564946 0.5129892
#> attr(,"scaled:scale")
#> [1] 1.224745 1.095445 0.836660 1.949359
normalize(x, 2) # normalizing columns
#>          [,1]     [,2]     [,3]     [,4]      [,5]
#> [1,] 2.323790 6.928203 3.133398 3.098387 0.5773503
#> [2,] 3.098387 6.928203 5.222330 1.549193 2.3094011
#> [3,] 3.872983 8.660254 4.177864 2.323790 2.3094011
#> [4,] 1.549193 8.660254 5.222330 3.872983 0.5773503
#> attr(,"scaled:scale")
#> [1] 1.2909944 0.5773503 0.9574271 1.2909944 1.7320508