Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork218
Seamless R and C++ Integration
License
RcppCore/Rcpp
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
TheRcpp package integrates R and C++ via R functions and a (header-only) C++ library.
All underlying R types and objects,i.e., everything aSEXP represents internallyin R, are matched to corresponding C++ objects. This covers anything from vectors,matrices or lists to environments, functions and more. EachSEXP variant isautomatically mapped to a dedicated C++ class. For example, numeric vectors arerepresented as instances of theRcpp::NumericVector class, environments arerepresented as instances ofRcpp::Environment, functions are represented asRcpp::Function, etc ... TheRcpp-introductionvignette (now published as aTAS paper; anearlier introductionwas also published as aJSS paperprovides a good entry point to Rcpp as do theRcppwebsite, theRcpppage and theRcppGallery. Full documentation is provided by theRcpp book.
Other highlights:
The conversion from C++ to R and back is driven by the templates
Rcpp::wrapandRcpp::aswhich are highly flexible and extensible, as documentedin theRcpp-extending vignette.Rcpp also provides Rcpp modules, a framework that allows exposingC++ functions and classes to the R level. TheRcpp-modules vignettedetails the current set of features of Rcpp-modules.
Rcpp includes a concept called Rcpp sugar that brings many R functionsinto C++. Sugar takes advantage of lazy evaluation and expression templatesto achieve great performance while exposing a syntax that is much nicerto use than the equivalent low-level loop code. 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 Rpackage development. Attributes are built on top of Rcpp modules andtheir implementation is based on previous work in the inline package.See theRcpp-atttributes vignettes for more details.
The package ships with ten pdf vignettes, including arecent introduction toRcpp nowpublished as apaper inTAS (and as apreprint in PeerJ). Also available is anearlierintroductionwhich was published as aJSS paper.
Among the other vignettes are theRcppFAQ and theintroduction toRcppAttributes.Additional documentation is available via theRcpp bookby Eddelbuettel (2013, Springer); see 'citation("Rcpp")' for details.
Rcpp follows the C++ motto of"you pay only for what you use" and imposesnorun-time performance penalty: Rcpp outperforms related packages indirect comparison, see for examplethis repo fordetails.
Compile-time performance can be tuned by selecting components. But it is alsoworth noting that use ofccache will (strongly)dominate all such possible component choices, we havepreviouslyrecommended its use.
TheRcpp Gallery showcases over one hundred fullydocumented and working examples. Thepackage RcppExamples contains a few basicexamples covering the core data types.
A number of examples are included, as are well over one thousand unit tests which provideadditional usage examples.
An earlier version of Rcpp, containing what we now call the 'classic RcppAPI' was written during 2005 and 2006 by Dominick Samperi. This code hasbeen factored out of Rcpp into the package RcppClassic, and it is stillavailable for code relying on the older interface. New development shouldalways use this Rcpp package instead.
Other usage examples are provided by packages using Rcpp. As of early July2025, there are 3043CRAN packages using Rcpp(corresponding to 13.6% of all packages, and 61.3% of packages containingcompiled code), a further 271BioConductorpackages in its current release as well as an unknown number of GitHub,Bitbucket, R-Forge, ... repositories using Rcpp. All these packages provideusage examples for Rcpp. The package is in widespread use and has beendownloaded over 100.6 million times (per the partial logs from the cloud mirrorsof CRAN).
Rcpp released on CRAN are carefully tested and curated. CRAN ensures they interoperatewith all other CRAN package on all test environment. The released and tested versionsare available via all mirrors ofCRAN network, and can beinstalled from within R via
install.packages("Rcpp")For the last several releases, we also made interimcandidate releases availableon theRcpp Drat Repo. Versions from adrat repo can be installed either byjust temporarily setting thedrat repo as in
install.packages("Rcpp",repos="https://RcppCore.github.io/drat")
or by setting adrat repo more permanently(as described in the documentation of thedratpackage).
Testing the release candidates prior to actual release help. Please run this if you can.
To install from source, ensure you have a complete package developmentenvironment for R as discussed in the relevant documentation; also seequestions 1.2 and 1.3 in theRcpp-FAQ.
If you want to run Rcpp on another (not-tested on CRAN) platform, or on releasesolder than the previous release, we suggest you do your due diligence and testaccordingly. Rcpp is provided by an all-volunteer team with finite resources.We work hard to test Rcpp with several thousand CRAN packages using it---butwe cannot test on outdated versions of 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 mustbe a subscriber in order to post. One can also consult the list archives to seeif your question has been asked before.
Theissue tickets at the GitHub repoare the primary bug reporting interface. As with the other web resources,previous issues can be searched as well.
Dirk Eddelbuettel, Romain Francois, JJ Allaire, Kevin Ushey, Qiang Kou,Nathan Russell, Iñaki Ucar, Doug Bates, and John Chambers
GPL (>= 2)
About
Seamless R and C++ Integration
Topics
Resources
License
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.