Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

findintervals

Find Interval Indices


Description

Find indices i in vector xs such that either x=xs[i] or such that xs[i]<x<xs[i+1] or xs[i]>x>xs[i+1].

Usage

findintervals(x, xs)

Arguments

x

single number.

xs

numeric vector, not necessarily sorted.

Details

Contrary to findInterval, the vector xs in findintervals need not be sorted.

Value

Vector of indices in 1..length(xs). If none is found, returns integer(0).

Note

If x is equal to the last element in xs, the index length(xs) will also be returned.

Examples

xs <- zapsmall(sin(seq(0, 10*pi, len=100)))
findintervals(0, xs)
#   1  10  20  30  40  50  60  70  80  90 100

pracma

Practical Numerical Math Functions

v2.3.3
GPL (>= 3)
Authors
Hans W. Borchers [aut, cre]
Initial release
2021-01-22

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.