Normalize numeric vector

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.

...

Parameters for other methods.

Value

Normalized numeric vector

Examples

nums <- c(runif(2), NA, -runif(2))
nums
#> [1]  0.41619516  0.09870208          NA -0.34861731 -0.53629164
normalization(nums, method = "max_min")
#> [1] 1.0000000 0.6666693 0.5630436 0.1970361 0.0000000
normalization(nums, method = "maximum")
#> [1]  0.7760613  0.1840455  0.0000000 -0.6500517 -1.0000000
normalization(nums, method = "sum")
#> [1]  0.29732342  0.07051125  0.00000000 -0.24904684 -0.38311849
normalization(nums, method = "softmax")
#> [1] 0.50767210 0.21807837 0.16769841 0.06631070 0.04024041
normalization(nums, method = "z_score")
#> [1]  1.3046197  0.4596384  0.1969510 -0.7308648 -1.2303443
normalization(nums, method = "mad")
#> [1]  0.8052377  0.1909648  0.0000000 -0.6744908 -1.0375955
normalization(nums, method = "unit_vector")
#> [1]  0.5408767  0.1282707  0.0000000 -0.4530543 -0.6969511
normalization(nums, method = "unit_vector", na_rm = FALSE)
#> [1]  0.5408767  0.1282707         NA -0.4530543 -0.6969511