scale_to_range | R Documentation |
Scale Numeric Vector to a Given Range
scale_to_range(x, min = 0, max = 1, ...)
x |
Numeric vector |
min |
Optional. Desired new minimum value. Defaults to 0. |
max |
Optional. Desired new maximum value. Defaults to 1. |
... |
Optional. Passed on to |
Numeric vector with minimum value of min
and
maximum value of max
.
# Simple numeric vector:
x <- c(-2, 0, 4)
# Scale to the c(0, 1) range:
scale_to_range(x)
# Leave minimum value untouched:
scale_to_range(x, min = -2, max = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.