R&D Rcpp: A Collection of Minimal Examples for Compiled Code in R

Tiny, buildable R packages that each demonstrate exactly one way to integrate C, C++, Fortran, or a parallel backend with R

programming
cpp
r
rcpp
Author

James Balamuta

Published

June 25, 2026

When you are learning to wrap compiled code in an R package, the hardest part is rarely the idea. It is the dozen small mechanical details that have to line up before anything compiles: where the header goes, what the Makevars flag is called, how the attribute is spelled, which file the generator writes. A full production package buries those details under everything else it is doing, and a documentation page describes them without letting you build them.

The R&D Rcpp collection takes the opposite approach. It is a set of minimal, complete, buildable R packages that each demonstrate exactly one technique for getting compiled code to talk to R. Every package is small enough to read in a sitting, passes R CMD check, and ships with continuous integration so you can see it building. When you are stuck on one specific thing, you can clone the example that does just that thing and nothing else.

The collection began in 2015 with a couple of header-layout examples and has grown over the years into a small library of patterns. The source lives under the coatless-rd-rcpp GitHub organization, and each package has a rendered site at rd-rcpp.thecoatlessprofessor.com/<package>/. This post is the map. Each entry below links to a write-up of the example and to its source.

Getting compiled code into a package

The starting point: how do you call a routine written in another language from R?

Organizing the source

Once you have more than one file, where does it all go?

Exposing C++ types to R

Moving richer objects, not just numbers, across the boundary.

Parallel and concurrent computing

Putting more than one core to work, correctly.

Using the examples

Every package installs the same way. With a compiler in hand:

# install.packages("remotes")
remotes::install_github("coatless-rd-rcpp/<package>")

From there, read the source, run R CMD check, and adapt the one piece you need. If you spot a gap in the collection or a pattern worth adding, the repositories are open at github.com/coatless-rd-rcpp.