centerscale: Center and scale vector

View source: R/util.R

centerscaleR Documentation

Center and scale vector

Description

Center and scale input vector using the specified method.

Usage

centerscale(v, type)

Arguments

v

Vector to center and scale.

type

Type of scaling: "center", "auto", "range", "iqrange", "vast", "pareto", "level" or "none".

Value

Center and scaled vector using the specified method.

References

Berg, R., Hoefsloot, H., Westerhuis, J., Smilde, A., and Werf, M. (2006). Centering, scaling, and transformations: improving the biological information content of metabolomics data. BMC Genomics 7, 142. DOI: 10.1186/1471-2164-7-142

Examples


v <- c(-100, 3, 4, 500, 10, 25, -8, -33, 321, 0, 2)

centerscale(v, "center")
# [1] -165.81818  -62.81818  -61.81818  434.18182  -55.81818  -40.81818
# [7]  -73.81818  -98.81818  255.18182  -65.81818  -63.81818

centerscale(v, "auto")
# [1] -0.9308937 -0.3526577 -0.3470437  2.4374717 -0.3133601 -0.2291509
# [7] -0.4144110 -0.5547596  1.4325760 -0.3694995 -0.3582716

centerscale(v, "range")
# [1] -0.2763636 -0.1046970 -0.1030303  0.7236364 -0.0930303 -0.0680303
# [7] -0.1230303 -0.1646970  0.4253030 -0.1096970 -0.1063636

centerscale(v, "iqrange")
# [1] -6.085071 -2.305254 -2.268557 15.933278 -2.048374 -1.497915 -2.708924
# [8] -3.626355  9.364470 -2.415346 -2.341952

centerscale(v, "vast")
# [1] -0.34396474 -0.13030682 -0.12823247  0.90064453 -0.11578638 -0.08467115
# [7] -0.15312466 -0.20498338  0.52933609 -0.13652987 -0.13238117

centerscale(v, "pareto")
# [1] -12.424134  -4.706731  -4.631804  32.531614  -4.182247  -3.058353
# [7]  -5.530919  -7.404075  19.119816  -4.931509  -4.781657

centerscale(v, "level")
# [1] -2.5193370 -0.9544199 -0.9392265  6.5966851 -0.8480663 -0.6201657
# [7] -1.1215470 -1.5013812  3.8770718 -1.0000000 -0.9696133

centerscale(v, "none")
# [1] -100    3    4  500   10   25   -8  -33  321    0    2


fakenmc/micompr documentation built on Aug. 6, 2024, 8:29 p.m.