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 of- xthat is higher than 0, and
- maxis the highest element of- xthat is lower than 1, then- trim_01()
- shifts all elements of - xthat are lower than- minupwards, so that they equal- min, and
- shifts all elements of - xthat are higher than- maxdownwards, so that they equal- max.
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
