'Rcpp' Bindings for 'Annoy', a Library for Approximate Nearest Neighbors

'Annoy' is a small C++ library for Approximate Nearest Neighbors written for efficient memory usage as well an ability to load from / save to disk. This package provides an R interface by relying on the 'Rcpp' package, exposing the same interface as the original Python wrapper to 'Annoy'. See < https://github.com/spotify/annoy> for more on 'Annoy'. 'Annoy' is released under Version 2.0 of the Apache License. Also included is a small Windows port of 'mmap' which is released under the MIT license.

Rcpp bindings for Annoy

What is Annoy?

Annoy is a small, fast and lightweight library for Approximate Nearest Neighbours with a particular focus on efficient memory use and the ability to load a pre-saved index.

Annoy is written by Erik Bernhardsson.

Why this package?

It provides a nice example for Rcpp Modules and use of templates: Annoy uses a template data type (generally float for efficiency) and one of two distance measures. This package shows that it is easy to wrap both.


The package matches the behaviour of the original Python package in the original Python wrapper for the Annoy library. It also replicates all unit tests written for the Python frontend, including a test for efficiently mmap-ing a binary index file.

The package originally built on Linux and OS X, and thanks to a patch by Qiang Kou now also builds on Windows.


You can either install from source via this repo, or install the CRAN package the usual way from R.


Dirk Eddelbuettel


GPL (>= 2)


Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.0.19 by Dirk Eddelbuettel, 6 months ago

https://github.com/eddelbuettel/rcppannoy, https://dirk.eddelbuettel.com/code/rcpp.annoy.html

Report a bug at https://github.com/eddelbuettel/rcppannoy/issues

Browse source code at https://github.com/cran/RcppAnnoy

Authors: Dirk Eddelbuettel

Documentation:   PDF Manual  

GPL (>= 2) license

Imports methods, Rcpp

Suggests tinytest

Linking to Rcpp

Imported by Seurat, scDHA, uwot.

See at CRAN