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.
remotes::install_github("BigelowLab/locate")
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.