README.md

minilocate

AppVeyor build
status Travis build
status Coverage
status

The goal of minilocate is to provide a way to search for a vector within another vector i.e. to find a needle in a haystack.

As far as I know, there’s no base function for finding one sequence inside another sequence.

The core code was originally written by Jonathan Carroll in a response to this post.

I’ve adapted the code to suit my needs:

Installation

You can install minilocate from github with:

# install.packages("devtools")
devtools::install_github("coolbutuseless/minilocate")

Examples

locate(c('m', 'n'), letters)
#> [1] 13
locate(c(0, 0, 1), sample(c(0, 1), 100, replace=TRUE))
#>  [1]  1 11 27 30 33 47 56 63 66 74 83 91 97
locate(c(T, F, F), c(T, F, F, T, F, T, F, F))
#> [1] 1 6
locate(as.raw(10:11), 1:100)
#> [1] 10
locate(c('5', '6'), 1:10)
#> [1] 5
locate(c(0, 1), c(0, 0, 1, 0, 0, 1), alignment = 2)
#> [1] 5


coolbutuseless/minilocate documentation built on May 20, 2019, 9:41 a.m.