suppressPackageStartupMessages({
  library(minilocate)
})

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-"
)

set.seed(1)

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)
locate(c(0, 0, 1), sample(c(0, 1), 100, replace=TRUE))
locate(c(T, F, F), c(T, F, F, T, F, T, F, F))
locate(as.raw(10:11), 1:100)
locate(c('5', '6'), 1:10)
locate(c(0, 1), c(0, 0, 1, 0, 0, 1), alignment = 2)


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