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,] 3.726780 2.2360680 3.726780 1.4907120 2.236068
#> [2,] 4.242641 4.2426407 5.656854 2.8284271 4.242641
#> [3,] 3.042903 0.6085806 2.434322 3.0429031 2.434322
#> [4,] 3.162278 2.5298221 1.264911 0.6324555 1.897367
#> attr(,"scaled:scale")
#> [1] 1.3416408 0.7071068 1.6431677 1.5811388
normalize(x, 2) # normalizing columns
#>      [,1]      [,2]     [,3]      [,4] [,5]
#> [1,]    5 2.3841582 3.973597 1.1547005    6
#> [2,]    3 2.3841582 3.178878 1.1547005    6
#> [3,]    5 0.7947194 3.178878 2.8867513    8
#> [4,]    5 3.1788777 1.589439 0.5773503    6
#> attr(,"scaled:scale")
#> [1] 1.000000 1.258306 1.258306 1.732051 0.500000