Learn R Programming

berryFunctions (version 1.22.5)

between: 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)

Value

Logical (boolean) vector with TRUE/FALSE values

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

Author

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

See Also

Examples

Run this code
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)  )

Run the code above in your browser using DataLab