Skip to contents

Normalize numeric vector

Usage

normalization(x, method = "max_min", na_rm = TRUE, ...)

Arguments

x

Input numeric vector.

method

Method used for normalization.

na_rm

Whether to remove NA values, and if setting TRUE, using 0 instead. Default is TRUE.

...

Parameters for other methods.

Value

Normalized numeric vector.

Examples

x <- c(runif(2), NA, -runif(2))
x
#> [1]  0.7698414  0.4976992         NA -0.7176185 -0.9919061
normalization(x, method = "max_min")
#> [1] 1.0000000 0.8455271 0.5630240 0.1556906 0.0000000
normalization(x, method = "maximum")
#> [1]  0.7761233  0.5017604  0.0000000 -0.7234742 -1.0000000
normalization(x, method = "sum")
#> [1]  0.2585907  0.1671778  0.0000000 -0.2410490 -0.3331825
normalization(x, method = "softmax")
#> [1] 0.43489931 0.30375921 0.15757627 0.06116481 0.04260040
normalization(x, method = "z_score")
#> [1]  1.1317755  0.7728963  0.1165706 -0.8297670 -1.1914754
normalization(x, method = "mad")
#> [1]  0.7235752  0.4677883  0.0000000 -0.6744908 -0.9322941
normalization(x, method = "unit_vector")
#> [1]  0.5033456  0.3254108  0.0000000 -0.4692007 -0.6485382
normalization(x, method = "unit_vector", na_rm = FALSE)
#> [1]  0.5033456  0.3254108         NA -0.4692007 -0.6485382