normalize | R Documentation |
Rescale a vector within a new range.
normalize(x, new.min, new.max, x.min = min(x), x.max = max(x))
normalise(x, new.min, new.max, x.min = min(x), x.max = max(x))
x |
Numeric vector or single value. |
new.min |
New minimum. |
new.max |
New maximum. |
x.min |
Current minimum. |
x.max |
Current maximum. |
The function rescale the data by using the formula:
a + (b - a) * (x - min(x))/(max(x) - min(x))
where a
is the new minimum of x
and b
the new maximum.
x <- 5:15
normalize(x, 0, 10)
normalize(x, -5, 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.