r1sd allows you to rescale a numeric vector such that the
ensuing output has a mean of 0 and a standard deviation of 1.
Value
The function returns a numeric vector rescaled with a mean of 0 and a standard deviation of 1.
Details
This is a convenience function since the default rescale() function
has some additional weirdness that is not welcome for my use cases. By default,
na.rm is set to TRUE.
Examples
x <- rnorm(100)
r1sd(x)
#> [1] -0.154847857 2.362856763 -0.125884922 0.677952554 -1.802642329
#> [6] -1.875585268 -0.524227548 0.221672707 -1.034228976 -0.617017301
#> [11] 0.669543916 0.004963047 -0.031505904 -0.635376861 1.197138388
#> [16] -0.781147047 -0.142775770 -0.640267083 -0.981868558 -0.616634691
#> [21] 1.522636139 1.554661990 0.154704007 0.249756798 -0.241963720
#> [26] 0.132898289 -0.193000399 0.436407002 -0.171704268 0.923658297
#> [31] 1.137825130 -0.925421726 -1.890348403 -1.404360498 -1.332392774
#> [36] -0.452078840 -1.793021007 0.114644798 0.916276634 -0.733212589
#> [41] -0.481252902 -1.270491519 1.265688249 1.121940131 1.230812596
#> [46] 0.773223175 0.466052510 -2.657796062 0.298005507 -1.094550679
#> [51] -0.969725720 1.369439617 -0.565408267 1.606734968 1.335067295
#> [56] -0.509703487 1.238095255 0.638314376 2.521002450 -0.631613852
#> [61] 1.065995689 -0.626406490 -0.447029303 -0.948383574 -0.549241673
#> [66] 0.668150619 0.884176937 -1.303876985 1.086802748 -0.029563290
#> [71] -0.651742016 0.479512652 -0.091040699 1.108529122 1.363926905
#> [76] -0.523006353 0.433352207 0.005161235 -0.627686109 1.545107873
#> [81] 0.290945116 0.177067770 0.225965890 -1.267653523 1.265688977
#> [86] 1.121562912 -1.628229421 0.242264642 -0.317379575 -0.813280463
#> [91] 0.596422504 -0.049505201 -0.605947433 -0.079567152 0.010370745
#> [96] -0.904593102 1.631521467 -0.111382725 -0.516015023 -0.970911661