Function standardizes numeric vector using multiple methods
standardize(x, method = "zs", na.rm = FALSE)
x | Numeric vector |
---|---|
method | Character string. Default is 'zs' (for z-score method). Other options include '01' (0 to 1 scaling) and 'pr' (percent rank) |
na.rm | Should NAs be removed? Default is |
Numeric vector with standardized values
#> [1] -1.2556843 -0.4080974 -0.1255684 0.1569605 -0.9731553 -0.4080974 1.2870764 #> [8] 1.8521343 -0.1255684standardize(x, method = "01")#> [1] 0.00000000 0.27272727 0.36363636 0.45454545 0.09090909 0.27272727 0.81818182 #> [8] 1.00000000 0.36363636standardize(x, method = "pr")#> [1] 0.000 0.250 0.500 0.750 0.125 0.250 0.875 1.000 0.500