which_interval: From a set of intervals, find which interval values belong to

View source: R/utils.R

which_intervalR Documentation

From a set of intervals, find which interval values belong to

Description

Returns which interval (if any) each number in a vector belongs to, given a set of user-defined intervals. Intervals can be specified using either two-column matrices or Intervals objects from the intervals package.

Usage

which_interval(x, Intv)

whichInterval(x, Intv)

Arguments

x

A vector of numeric values

Intv

A two-column matrix or an object of class Intervals

Value

For each value in x: if x[i] is in the set of intervals, the index of the corresponding interval(s), NA if no interval contains x[i]

Author(s)

Simon Barthelme

See Also

%In%

Examples

start <- c(0, 1, 2)
end <- c(.5, 1.3, 3)
intv <- cbind(start, end) # The 1st interval is 0.0-0.5, 2nd is 1.0-1.3, etc.
which_interval(seq(0, 3, l = 10), intv)

eyelinker documentation built on Feb. 24, 2026, 1:06 a.m.