TheRcpppackage integrates R and C++ via R functions and a (header-only) C++library.
All underlying R types and objects,i.e., everything aSEXP represents internally in R, are matched tocorresponding C++ objects. This covers anything from vectors, matricesor lists to environments, functions and more. EachSEXPvariant is automatically mapped to a dedicated C++ class. For example,numeric vectors are represented as instances of theRcpp::NumericVector class, environments are represented asinstances ofRcpp::Environment, functions are representedasRcpp::Function, etc … TheRcpp-introductionvignette (now published as aTAS paper; anearlierintroduction was also published as aJSS paper provides agood entry point to Rcpp as do theRcppwebsite, theRcpp page andtheRcpp Gallery. Fulldocumentation is provided by theRcppbook.
Other highlights:
The conversion from C++ to R and back is driven by the templatesRcpp::wrap andRcpp::as which are highlyflexible and extensible, as documented in theRcpp-extendingvignette.
Rcpp also provides Rcpp modules, a framework that allows exposingC++ functions and classes to the R level. TheRcpp-modulesvignette details the current set of features of Rcpp-modules.
Rcpp includes a concept called Rcpp sugar that brings many Rfunctions into C++. Sugar takes advantage of lazy evaluation andexpression templates to achieve great performance while exposing asyntax that is much nicer to use than the equivalent low-level loopcode. TheRcpp-sugargives an overview of the feature.
Rcpp attributes provide a high-level syntax for declaring C++functions as callable from R and automatically generating the coderequired to invoke them. Attributes are intended to facilitate bothinteractive use of C++ within R sessions as well as to support R packagedevelopment. Attributes are built on top of Rcpp modules and theirimplementation is based on previous work in the inline package. See theRcpp-atttributesvignettes for more details.
The package ships with ten pdf vignettes, including arecentintroduction to Rcpp now published as apaper in TAS(and as apreprint inPeerJ). Also available is anearlierintroduction which was published as aJSS paper.
Among the other vignettes are theRcppFAQ and the introduction toRcppAttributes. Additional documentation is available via theRcppbook by Eddelbuettel (2013, Springer); see ‘citation(“Rcpp”)’ fordetails.
Rcpp follows the C++ motto of“you pay only for what youuse” and imposes norun-time performance penalty: Rcppoutperforms related packages in direct comparison, see for examplethis repo fordetails.
Compile-time performance can be tuned by selecting components. But itis also worth noting that use ofccache will (strongly)dominate all such possible component choices, we havepreviouslyrecommended its use.
TheRcpp Gallery showcasesover one hundred fully documented and working examples. ThepackageRcppExamples contains a few basic examples covering the core datatypes.
A number of examples are included, as are well over one thousand unittests which provide additional usage examples.
An earlier version of Rcpp, containing what we now call the ‘classicRcpp API’ was written during 2005 and 2006 by Dominick Samperi. Thiscode has been factored out of Rcpp into the package RcppClassic, and itis still available for code relying on the older interface. Newdevelopment should always use this Rcpp package instead.
Other usage examples are provided by packages using Rcpp. As of earlyJuly 2025, there are 3043CRANpackages using Rcpp (corresponding to 13.6% of all packages, and 61.3%of packages containing compiled code), a further 271BioConductor packages in itscurrent release as well as an unknown number of GitHub, Bitbucket,R-Forge, … repositories using Rcpp. All these packages provide usageexamples for Rcpp. The package is in widespread use and has beendownloaded over 100.6 million times (per the partial logs from the cloudmirrors of CRAN).
Rcpp released on CRAN are carefully tested and curated. CRAN ensuresthey interoperate with all other CRAN package on all test environment.The released and tested versions are available via all mirrors ofCRAN network, and can be installedfrom within R via
install.packages("Rcpp")For the last several releases, we also made interimcandidate releases available on theRcpp Drat Repo. Versionsfrom adrat repo canbe installed either by just temporarily setting thedrat repo as in
install.packages("Rcpp",repos="https://RcppCore.github.io/drat")or by setting adrat repo morepermanently (as described in the documentation of thedrat package).
Testing the release candidates prior to actual release help. Pleaserun this if you can.
To install from source, ensure you have a complete packagedevelopment environment for R as discussed in the relevantdocumentation; also see questions 1.2 and 1.3 in theRcpp-FAQ.
If you want to run Rcpp on another (not-tested on CRAN) platform, oron releases older than the previous release, we suggest you do your duediligence and test accordingly. Rcpp is provided by an all-volunteerteam with finite resources. We work hard to test Rcpp with severalthousand CRAN packages using it—but we cannot test on outdated versionsof R or your OS.
The best place for questions is theRcpp-develmailing list hosted at R-forge. Note that in order to keep spam down,you must be a subscriber in order to post. One can also consult the listarchives to see if your question has been asked before.
Theissue ticketsat the GitHub repo are the primary bug reporting interface. As withthe other web resources, previous issues can be searched as well.
Dirk Eddelbuettel, Romain Francois, JJ Allaire, Kevin Ushey, QiangKou, Nathan Russell, Iñaki Ucar, Doug Bates, and John Chambers
GPL (>= 2)