grapes-within-grapes: Find if value belongs to a set of intervals

%within%R Documentation

Find if value belongs to a set of intervals

Description

Returns whether numeric values on the left-hand side of the operator fall within any of the specified intervals on the right-hand side. Intervals can be specified using either two-column matrices or Intervals objects from the intervals package.

Usage

x %within% Intv

x %In% Intv

Arguments

x

A vector of numeric values

Intv

A set of intervals, defined by a two-column matrix of endpoints or an Intervals object

Value

A vector of logicals, which are true if x[i] belongs to any of the intervals in the set.

Author(s)

Simon Barthelme

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.
c(0, 0.6, 1.5, 3) %within% intv

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