it zips the index in the basket!
Zips two sorted arrays into each other. That's it. Not for CRAN.
-- Steven E. Pav, shabbychef@gmail.com
This package can be installed via drat, or from github:
# via drat:
if (require(drat)) {
drat:::add("shabbychef")
install.packages("zipper")
}
# get snapshot from github (may be buggy)
if (require(devtools)) {
install_github("shabbychef/zipper")
}
Suppose you have two sorted arrays and need to align them. That's a zip operation. Back when I worked with time series (in Matlab), a zip operation was at the base of the 'look back' join operation. That is all this package does:
require(zipper)
set.seed(1234)
reference_x <- sort(rnorm(10000))
lookup_y <- sort(rnorm(100))
idxs <- zipper::zip_le(reference_x, lookup_y)
head(idxs)
## [1] 104 106 119 126 155 165
# compare to this slow version:
altv <- rep(NA_integer_, length(lookup_y))
for (iii in seq_along(lookup_y)) {
altv[iii] <- sum(reference_x <= lookup_y[iii])
}
stopifnot(all.equal(altv, idxs))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.