locate: Interpolate the locations of values within an ordered vector...

Description Usage Arguments Value Examples

View source: R/locate.R

Description

Inpsired by locate() from numerical recipes, findInterval and VALUE_LOCATE() from IDL.

Usage

1
locate(x, vec, ...)

Arguments

x

vector of values (in any order) including sortable character types

vec

ordered vector (ascending or descending) of same type as x

...

other arguments for sapply

Value

vector of indices ranging from 0 to the length of vec

Examples

1
2
3
4
5
6
7
8
## Not run: 
  x <- c(13, 7, 22)
  locate(x, 10:19)
  locate(x, 19:10)
  locate(c("zoo", "dog", "fish", "cat"), letters)
  locate(c("zoo", "dog", "fish", "cat"), letters, USE.NAMES = FALSE)

## End(Not run)

BigelowLab/locate documentation built on Dec. 17, 2021, 10:51 a.m.