between function

Detect where values fall in a specified range

Detect where values fall in a specified range

This is a shortcut for x >= left & x <= right, implemented for local vectors and translated to the appropriate SQL for remote tables.

between(x, left, right)

Arguments

  • x: A vector
  • left, right: Boundary values. Both left and right are recycled to the size of x.

Returns

A logical vector the same size as x.

Details

x, left, and right are all cast to their common type before the comparison is made.

Examples

between(1:12, 7, 9) x <- rnorm(1e2) x[between(x, -1, 1)] # On a tibble using `filter()` filter(starwars, between(height, 100, 150))

See Also

join_by() if you are looking for documentation for the between() overlap join helper.

  • Maintainer: Hadley Wickham
  • License: MIT + file LICENSE
  • Last published: 2023-11-17