R: Index-finding in a Sorted Vector

indx {lsei} | R Documentation

## Index-finding in a Sorted Vector

### Description

For each of given values, `indx` finds the index of the value in a vector sorted in ascending order that the given value is barely greater than or equal to.

### Usage

    indx(x, v)

### Arguments

`x` | vector of numeric values, the indices of which are to be found.
`v` | vector of numeric values sorted in ascending order.

### Details

For each x[i], the function returns integer j such that

v[j] <= x[i] < v[j+1]

where v[0] = -Inf and v[n+1] = Inf.

### Value

Returns a vector of integers, that are indices of x-values in vector v.

### Author(s)

Yong Wang <yongwang@auckland.ac.nz>

### Examples

    indx(0:6,c(1:5,5))
    indx(sort(rnorm(5)),-2:2)

[Package lsei version 1.2-0 Index]