Skip to contents

Standarizes a vector or matrix, i.e., scales all the values in a way that the transformed values will be within the range [0, 1].

Usage

stdx(x, ...)

Arguments

x

vector, matrix or data.frame to be scaled

...

further arguments passed to or from other methods

Details

$$z = \frac{x - x_{min}}{x_{max}-x_{min}}$$

Author

Mauricio Zambrano-Bigiarini, mzb.devel@gmail

See also

Examples

############
## Loading the monthly time series of precipitation within the Ebro River basin.
data(EbroPPtsMonthly)

# Standarizing only some values of 'EbroPPtsMonthly'
stdx(as.matrix(EbroPPtsMonthly[1:70,10:13]))
#>         P9041       P9048       P9056       P9060
#> 4  0.56844420 0.582990398 0.421291053 0.100515464
#> 5  0.41396372 0.338477366 0.216024915 0.123116574
#> 6  0.42495877 0.194787380 0.159116648 0.164155432
#> 7  0.21715228 0.331618656 0.114382786 0.071966693
#> 8  0.82023090 0.599451303 1.000000000 1.000000000
#> 9  0.42275976 0.319615912 0.214609287 0.246827914
#> 10 0.08081363 0.050411523 0.012174405 0.014472641
#> 11 0.17207257 0.193415638 0.137599094 0.044607454
#> 12 0.32105553 0.239026063 0.130237826 0.076328311
#> 13 0.17921935 0.280864198 0.079841450 0.069389374
#> 14 0.55964816 0.287722908 0.236126840 0.205194290
#> 15 0.24079164 0.284293553 0.021234428 0.100118953
#> 16 1.00000000 0.629286694 0.619479049 0.421689136
#> 17 0.14678395 0.261316872 0.034541336 0.064631245
#> 18 0.24683892 0.120713306 0.045300113 0.087034100
#> 19 0.41946124 0.383744856 0.353340883 0.156026963
#> 20 0.27652556 0.063443073 0.067667044 0.032513878
#> 21 0.12699285 0.241426612 0.099093998 0.031126090
#> 22 0.32380429 0.061728395 0.020101925 0.126486915
#> 23 0.45519516 0.305898491 0.533125708 0.089413164
#> 24 0.46509071 0.372770919 0.251132503 0.265463918
#> 25 0.30511270 0.117283951 0.114665912 0.093774782
#> 26 0.00000000 0.051440329 0.011325028 0.000000000
#> 27 0.15283123 0.228395062 0.090033975 0.136003172
#> 28 0.44474986 0.278463649 0.139014723 0.168913561
#> 29 0.23859263 0.156721536 0.159682899 0.079500397
#> 30 0.09675646 0.073731139 0.060305776 0.064829500
#> 31 0.23199560 0.105624143 0.127123443 0.000000000
#> 32 0.45409566 0.278463649 0.133918460 0.108445678
#> 33 0.10720176 0.064128944 0.071064553 0.048770817
#> 34 0.15173172 0.029149520 0.012174405 0.060666138
#> 35 0.06706982 0.073045267 0.010758777 0.015463918
#> 36 0.53106102 0.281550069 0.235560589 0.113798573
#> 37 0.14403518 0.174554184 0.058607022 0.056304520
#> 38 0.54370533 0.264060357 0.313703284 0.141950833
#> 39 0.61572292 1.000000000 0.347678369 0.193893735
#> 40 0.03573392 0.004801097 0.013873160 0.071371927
#> 41 0.85101704 0.357338820 0.464609287 0.265067407
#> 42 0.21990104 0.124142661 0.174405436 0.089809675
#> 43 0.36943375 0.153978052 0.129388448 0.000000000
#> 44 0.21220451 0.177983539 0.146659117 0.127279937
#> 45 0.18471688 0.124142661 0.099660249 0.074544013
#> 46 0.08411215 0.160836763 0.097678369 0.035289453
#> 47 0.55250137 0.219821674 0.144677237 0.145717684
#> 48 0.28971963 0.207475995 0.124292186 0.085646312
#> 49 0.64595932 0.345336077 0.364665912 0.346748612
#> 50 0.45024739 0.248971193 0.258493771 0.268437748
#> 51 0.31775701 0.301440329 0.092865232 0.110031721
#> 52 0.57724024 0.358710562 0.465175538 0.184773989
#> 53 0.05002749 0.000000000 0.000000000 0.037866772
#> 54 0.01209456 0.090192044 0.051528879 0.038263283
#> 55 0.00000000 0.019547325 0.037372593 0.000000000
#> 56 0.32380429 0.239711934 0.097678369 0.139770024
#> 57 0.30676196 0.057270233 0.075028313 0.046788263
#> 58 0.39417262 0.121056241 0.062853907 0.083663759
#> 59 0.41121495 0.338134431 0.195073613 0.070182395
#> 60 0.07421660 0.119684499 0.008493771 0.045400476
#> 61 0.33424959 0.237997257 0.198471121 0.195281523
#> 62 0.26278175 0.135116598 0.166194790 0.126685170
#> 63 0.44969764 0.293895748 0.272650057 0.127874703
#> 64 0.19351292 0.138545953 0.018969422 0.113203807
#> 65 0.30841121 0.123456790 0.113533409 0.098731166
#> 66 0.38647609 0.147462277 0.166761042 0.170499603
#> 67 0.36833425 0.361454047 0.269818800 0.247422680
#> 68 0.52006597 0.302469136 0.097678369 0.071173672
#> 69 0.08356240 0.151577503 0.135050963 0.036280730
#> 70 0.06706982 0.018518519 0.005662514 0.007335448
#> 71 0.03243540 0.086762689 0.032559456 0.003965107
#> 72 0.27377680 0.059327846 0.050962627 0.129064235
#> 73 0.05497526 0.085048011 0.026330691 0.040047581