Extending R with C++: A Brief Introduction to Rcpp

Debian and R Projects, Chicago, IL, United States
Department of Informatics, University of Illinois at Urbana-Champaign, Champaign, IL, United States
Department of Statistics, University of Illinois at Urbana-Champaign, Champaign, IL, United States
DOI
10.7287/peerj.preprints.3188v1
Subject Areas
Data Science
Keywords
applications and case studies, simulation, computationally intensive methods, statistical computing
Copyright
© 2017 Eddelbuettel et al.
Licence
This is an open access article distributed under the terms of the Creative Commons Attribution License, which permits unrestricted use, distribution, reproduction and adaptation in any medium and for any purpose provided that it is properly attributed. For attribution, the original author(s), title, publication source (PeerJ Preprints) and either DOI or URL of the article must be cited.
Cite this article
Eddelbuettel D, Balamuta JJ. 2017. Extending R with C++: A Brief Introduction to Rcpp. PeerJ Preprints 5:e3188v1

Abstract

R has always provided an application programming interface (API) for extensions. Based on the C language, it uses a number of macros and other low-level constructs to exchange data structures between the R process and any dynamically-loaded component modules authors added to it. With the introduction of the Rcpp package, and its later refinements, this process has become considerably easier yet also more robust. By now, Rcpp has become the most popular extension mechanism for R. This article introduces Rcpp, and illustrates with several examples how the Rcpp Attributes mechanism in particular eases the transition of objects between R and C++ code.

Author Comment

This has been submitted to the American Statistician (TAS) as part of the Data Science Collection by Jennifer Bryan and Hadley Wickham.

Supplemental Information

Source code embedded within the paper

DOI: 10.7287/peerj.preprints.3188v1/supp-1