Deals appropriately with objects with a few very large elements
Arguments
- x
Vector of real or complex values
- upper
Upper limit
- lower
Lower limit
- na
Boolean, with default FALSE
meaning to “clip”
x
(if real) by setting elements of x
with x>high
to
high
; if TRUE
, set such elements to NA
.
If x
is complex, this argument is ignored
Details
If x
is complex, low
is ignored and the function returns
x
, after executing x[abs(x)>high] <- NA
.
Author
Robin K. S. Hankin
Examples
x <- c(rep(1,5),300, -200)
limit(x,100)
#> [1] 1.00 1.00 1.00 1.00 1.00 100.00 -187.94
limit(x,upper=200,lower= -400)
#> [1] 1 1 1 1 1 200 -200
limit(x,upper=200,lower= -400,na=TRUE)
#> [1] 1 1 1 1 1 NA -200