README.md

locate

Interpolate the locations of values within an ordered vector viewed from left to right.

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

Requirements

Installation

remotes::install_github("BigelowLab/locate")

Examples

library(locate)

x <- c(13, 7, 22)
locate(x, 10:19)
## [1]  4  0 10
locate(x, 19:10)
## [1]  7 10  0
x <- c("zoo", "dog", "fish", "cat")
locate(x, letters)
##  zoo  dog fish  cat 
##   26    4    6    3
locate(x, letters, USE.NAMES = FALSE)
## [1] 26  4  6  3


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