Merges intervals

## S3 method for class 'numeric}(intervals, ...)':

 Merges intervals by returning an index vector specifying the (first)
  interval that each value maps to, if any.

 intervals{The N intervals to be merged.
      If an Nx2 numeric matrix, the first column should be the lower
      bounds and the second column the upper bounds of each interval.
      If a numeric vector of length 2N, each consecutive pair should
      be the lower and upper bounds of an interval.
   ...{Not used.}

 Returns a matrix (or a vector) of M intervals, where M <= n.="" the="" intervals="" are="" ordered="" by="" their="" lower="" bounds.="" @mode="" of="" returned="" is="" same="" as="" mode="" input="" intervals.<="" value="">

The upper and lower bounds are considered to be inclusive, that is, all intervals are interpreted to be of form [a,b]. There is currently no way to specify intervals with open bounds, e.g. (a,b]. Furthermore, the bounds are currently treated as real values. For instance, merging [0,1] and [2,3] will return the same intervals. Note, if integer intervals were treated specially, we would merge these intervals to integer interval [0,3] == {0,1,2,3}.
[object Object] inAnyInterval(). match(). methods utilities programming
  • mergeIntervals.numeric
  • mergeIntervals.numeric
Documentation reproduced from package R.utils, version 1.1.0, License: LGPL (>= 2.1)

Community examples

Looks like there are no examples yet.