Trim a vector so that all values are greater than 0 and less than 1.
Arguments
- x
 A numeric vector. Can be an rvec.
Details
If
minis lowest element ofxthat is higher than 0, andmaxis the highest element ofxthat is lower than 1, thentrim_01()shifts all elements of
xthat are lower thanminupwards, so that they equalmin, andshifts all elements of
xthat are higher thanmaxdownwards, so that they equalmax.
See also
logit(),invlogit()Logit transformation
Examples
x <- c(1, 0.98, -0.001, 0.5, 0.01)
trim_01(x)
#> [1] 0.98 0.98 0.01 0.50 0.01
