make_scale | R Documentation |
make_scale()
will rescale any vector to have a user-defined minimum and maximum.
make_scale(x, minim, maxim)
x |
a numeric vector |
minim |
a desired numeric minimum |
maxim |
a desired numeric maximum |
This function is useful if you wanted to do some kind of minimum-maximum rescaling of a variable on some given scale, prominently rescaling to a minimum of 0 and a maximum of 1 (thinking ahead to a regression). The function is flexible enough for any minimum or maximum.
The function takes a numeric vector and returns a rescaled version of it with the observed (desired) minimum, the observed (desired) maximum, and rescaled values between both extremes.
x <- runif(100, 1, 100)
make_scale(x, 2, 5) # works
make_scale(x, 5, 2) # results in message
make_scale(x, 0, 1) # probably why you're using this.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.