inside: Check Whether Numeric Value Falls Inside Two Other Numeric...

Description Usage Arguments Value Examples

View source: R/inside.R

Description

Returns TRUE if x falls inside range defined by ends and FALSE otherwise. Also works for multiple sets of values and/or endpoints.

Usage

1
inside(x, ends, inclusive = TRUE)

Arguments

x

Numeric value or vector of numeric values.

ends

Numeric vector of length 2 specifying the endpoints for the interval, or a 2-column numeric matrix where each row specifies a pair of endpoints.

inclusive

Logical value indicating whether endpoints should be included.

Value

Logical value or vector.

Examples

1
2
3
4
5
6
7
8
# Check whether 2 is inside [0, 2.5]
inside(1, c(0, 2.5))

# Check whether 2 and 3 are inside (0, 3)
inside(c(2, 3), c(0, 3), inclusive = FALSE)

# Check whether 1 is inside [1, 2] and [3, 4]
inside(1, rbind(c(1, 2), c(3, 4)))

dvmisc documentation built on Dec. 18, 2019, 1:35 a.m.