in_range | R Documentation |
Do numeric values fall into specified ranges?
in_range(x, left, right, closed = TRUE)
x |
a numeric vector of values |
left, right |
boundary values or vectors of same length as x |
closed |
wether to include ( |
a logical vector of the same length as the input
in_range(1:5, 2, 4)
in_range(1:5, 2, 4, closed=c(FALSE, TRUE)) # left-open
in_range(1:5, 6:2, 3) # vector of boundaries, single values recycle
# plays nicely with dplyr
df <- tibble::tibble(x=rep(4,5), left=1:5, right=3:7)
dplyr::mutate(df,
closed=in_range(x, left, right, TRUE),
open=in_range(x, left, right, FALSE))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.