clamp | R Documentation |
Clamp a numeric vector between a minimum and maximum value.
clamp(x, minval = -Inf, maxval = Inf)
clamp0(x, minval = 0, maxval = 1)
scale2range(x, minval = 0, maxval = 1, na.rm = TRUE)
x |
The vector/matrix to clamp. |
minval |
Minimum value; all lower values are clamped to this value. |
maxval |
Maximum value; all higher values are clamped to this value. |
na.rm |
for |
Clamped vector.
clamp()
: Set all values exceeding the minimum and maximum to
the minimum and maximum value, respectively.
clamp0()
: Same as clamp())
but with a default range of 0 to 1.
scale2range()
: Rescales the vector such that it fits neatly between
the given minimum and maximum values.
Sercan Kahveci
clamp(0:10,2,8)
clamp0(rnorm(10))
scale2range(rnorm(10))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.