Matrix Scaling Utilities
col01scale.Rdcol01scale and colcenter (re)scale the columns of a
matrix. These are simple one-line utilities, mainly with a didactical
purpose.
See also
The standard R function scale().
Examples
## See the simple function definitions:
colcenter ## simply one line
#> function (mat)
#> sweep(mat, 2, apply(mat, 2, mean))
#> <bytecode: 0x5ec1af8da4c0>
#> <environment: namespace:sfsmisc>
col01scale# almost as simple
#> function (mat, scale.func = function(x) diff(range(x)), location.func = mean)
#> {
#> mat <- sweep(mat, 2, apply(mat, 2, location.func))
#> sweep(mat, 2, apply(mat, 2, scale.func), "/")
#> }
#> <bytecode: 0x5ec1af764460>
#> <environment: namespace:sfsmisc>