Learn R Programming

assertions (version 0.3.0)

is_between: Check if a numeric vector is between a specified minimum and maximum value

Description

This function checks if a numeric vector is between a specified minimum and maximum value. It can also optionally check if all elements of the vector must be between the thresholds or if only one element is sufficient

Usage

is_between(x, minimum, maximum, inclusive = TRUE)

Value

A logical value indicating whether all elements of the numeric vector x are between the specified minimum and maximum values

Arguments

x

a numeric vector to check

minimum

The minimum value to compare against

maximum

The maximum value to compare against

inclusive

should comparisons allow equality with the minimum and maximum values? (flag)

Examples

Run this code
if(interactive()){
is_between(c(2,3,4), 1, 4) # TRUE
is_between(c(2,3,4), 2, 4) # TRUE
is_between(c(2,3,1), 2, 4) # FALSE
}

Run the code above in your browser using DataLab