trim
trim.Rd
Cut a numeric vector between min and max. Values lower than min or higher than max are substituted with the provided values.
Examples
x <- runif(20, 0, 20)
trim(x, min = 5, max = 10)
#> [1] 10.000000 10.000000 8.655763 10.000000 10.000000 8.714363 10.000000
#> [8] 10.000000 5.000000 10.000000 5.000000 10.000000 10.000000 5.000000
#> [15] 10.000000 10.000000 8.147227 10.000000 10.000000 7.083735
trim(x, max = 10)
#> [1] 10.000000 10.000000 8.655763 10.000000 10.000000 8.714363 10.000000
#> [8] 10.000000 2.562315 10.000000 2.580325 10.000000 10.000000 4.835522
#> [15] 10.000000 10.000000 8.147227 10.000000 10.000000 7.083735
trim(x, min = 5)
#> [1] 17.731010 12.000747 8.655763 18.405516 12.320289 8.714363 17.946088
#> [8] 15.380270 5.000000 10.772662 5.000000 10.219298 10.875854 5.000000
#> [15] 16.062882 18.958274 8.147227 10.294891 19.630837 7.083735