inside {dvmisc}R Documentation

Check Whether Numeric Value Falls Inside Two Other Numeric Values

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

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

# 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)))


[Package dvmisc version 1.1.4 Index]