grapes-btw-grapes.RdThe binary operator %btw% returns a logical vector indicating all values in a vector that fall within a specified lower and upper limit.
x %btw% yA numeric vector.
Either a numeric vector specifying a lower and upper
limit, or a character string in the form '(x,y)',
'[x,y]', '(x,y]', or '[x,y)'.
Here x and y denote the lower and upper
limits, while square brackets indicate the end point
is included, while round parentheses indicate the end
point is excluded.
A logical vector.
x <- 1:10
# Limits specified as numeric vector
x[ x %btw% c( 3, 6 ) ]
#> [1] 4 5 6
# Limits specified as character string
x[ x %btw% '(3,6)' ]
#> [1] 4 5
x[ x %btw% '[3,6]' ]
#> [1] 3 4 5 6
x[ x %btw% '(3,6]' ]
#> [1] 4 5 6
x[ x %btw% '[3,6)' ]
#> [1] 3 4 5