between: Are values between a and b?

View source: R/between.R

betweenR Documentation

Are values between a and b?

Description

Are values within a certain interval? Basically a wrapper for x >= a & x <= b to save repeating long x names twice.

Usage

between(x, a, b = a, incl = TRUE, aincl = incl, bincl = incl, quiet = FALSE)

Arguments

x

Numerical vector

a, b

Numerical values/vectors specifying the borders of the interval. min and max are used, so they can be a vector.

incl

Logical. Include values on the borders? For x == border, TRUE will be returned. Specify per left and right border separately with the arguments aincl and bincl. DEFAULT: TRUE

aincl, bincl

Logical. Include values on left and right border, respectively? DEFAULT: incl

quiet

Logical. Suppress warning if a>b? DEFAULT: FALSE

Value

Logical (boolean) vector with TRUE/FALSE values

Author(s)

Berry Boessenkool, berry-b@gmx.de, Aug 2017

See Also

findInterval

Examples

between(1:10, 4, 8)
between(1:10, 4:8) # range as vector
between(1:10, 8, 4) # warns about interval

data.frame( incl.T=between(1:10, 4, 8),
            incl.F=between(1:10, 4, 8,  incl=FALSE),
           aincl.F=between(1:10, 4, 8, aincl=FALSE),
           bincl.F=between(1:10, 4, 8, bincl=FALSE)  )


berryFunctions documentation built on May 29, 2024, 4:01 a.m.