scale_uniform {dynutils} | R Documentation |
Rescale data to have a certain center and max range.
Description
scale_uniform
uniformily scales a given matrix such that
the returned space is centered on center
, and each column was scaled equally
such that the range of each column is at most max_range
.
Usage
scale_uniform(x, center = 0, max_range = 1)
Arguments
x |
A numeric vector matrix or data frame. |
center |
The new center point of the data. |
max_range |
The maximum range of each column. |
Value
The centered, scaled matrix. The numeric centering and scalings used are returned as attributes.
Examples
## Generate a matrix from a normal distribution
## with a large standard deviation, centered at c(5, 5)
x <- matrix(rnorm(200*2, sd = 10, mean = 5), ncol = 2)
## Center the dataset at c(0, 0) with a minimum of c(-.5, -.5) and a maximum of c(.5, .5)
x_scaled <- scale_uniform(x, center = 0, max_range = 1)
## Plot rescaled data
plot(x_scaled)
## Show ranges of each column
apply(x_scaled, 2, range)
[Package dynutils version 1.0.11 Index]