Search notes:

R function: findInterval

findInterval searches in a vector of »ranges« for the interval that a given value belongs to.
#             |       |           |        |
ranges    <- c(0  ,  2.5     ,   6.5 ,  10 );
quality   <- c( 'low' , 'medium',   'high' )
#             |       |           |        |


values   <- c( 4, 1, 7, 8, 6);
intervals<- findInterval(values, intervals);

quality[intervals]
#
#  "medium" "low"    "high"   "high"   "medium"
Github repository about-r, path: /functions/findInterval.R
The findInterval function can be used in switch statement to test for ranges.

See also

The dplyr function case_when.
Index to (some) R functions

Index