# set the knitr options ... for everyone! # if you unset this, then vignette build bonks. oh, joy. #opts_knit$set(progress=TRUE) opts_knit$set(eval.after='fig.cap') # for a package vignette, you do want to echo. # opts_chunk$set(echo=FALSE,warning=FALSE,message=FALSE) opts_chunk$set(warning=FALSE,message=FALSE) #opts_chunk$set(results="asis") opts_chunk$set(cache=TRUE,cache.path="cache/") #opts_chunk$set(fig.path="figure/",dev=c("pdf","cairo_ps")) opts_chunk$set(fig.path="tools/figure/",dev=c("png")) opts_chunk$set(fig.width=7,fig.height=6,dpi=100,out.width='700px',out.height='600px') # doing this means that png files are made of figures; # the savings is small, and it looks like shit: #opts_chunk$set(fig.path="figure/",dev=c("png","pdf","cairo_ps")) #opts_chunk$set(fig.width=4,fig.height=4) # for figures? this is sweave-specific? #opts_knit$set(eps=TRUE) # this would be for figures: #opts_chunk$set(out.width='.8\\textwidth') # for text wrapping: options(width=96,digits=2) opts_chunk$set(size="small") opts_chunk$set(tidy=TRUE,tidy.opts=list(width.cutoff=50,keep.blank.line=TRUE)) library(ggplot2) library(zipper) library(dplyr) library(moments) library(microbenchmark) # chicken and egg dept: # [![CRAN](http://www.r-pkg.org/badges/version/zipper)](http://cran.rstudio.com/package=zipper) # [![Downloads](http://cranlogs.r-pkg.org/badges/zipper?color=brightgreen)](http://www.r-pkg.org/pkg/zipper) # [![Total](http://cranlogs.r-pkg.org/badges/grand-total/zipper?color=brightgreen)](http://www.r-pkg.org/pkg/zipper) #[![CRAN](http://www.r-pkg.org/badges/version/zipper)](https://cran.r-project.org/package=zipper) #[![Downloads](http://cranlogs.r-pkg.org/badges/zipper?color=green)](http://www.r-pkg.org/pkg/zipper) #[![Total](http://cranlogs.r-pkg.org/badges/grand-total/zipper?color=green)](http://www.r-pkg.org/pkg/zipper)
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) # 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.