|
1 | | -Rcpp |
2 | | -==== |
| 1 | +Rcpp: Seamless R and C++ Integration |
| 2 | +==================================== |
3 | 3 |
|
4 | 4 | [](https://travis-ci.org/RcppCore/Rcpp) |
| 5 | + |
| 6 | +The Rcpp package provides R functions as well as a C++ library |
| 7 | +which facilitate the integration of R and C++ |
| 8 | + |
| 9 | +R data types (`SEXP`) are matched to C++ objects in a class hierarchy. All R |
| 10 | +types are supported (vectors, functions, environment, etc ...) and each |
| 11 | +type is mapped to a dedicated class. For example, numeric vectors are |
| 12 | +represented as instances of the Rcpp::NumericVector class, environments are |
| 13 | +represented as instances of Rcpp::Environment, functions are represented as |
| 14 | +Rcpp::Function, etc ... |
| 15 | +The |
| 16 | +[Rcpp-introduction](http://cran.r-project.org/web/packages/Rcpp/vignettes/Rcpp-introduction.pdf) |
| 17 | +vignette (also published as [in JSS in 2011](http://www.jstatsoft.org/v40/i08/)) provides a good |
| 18 | +entry point to Rcpp, as does the [Rcpp website](http://www.rcpp.org) and the |
| 19 | +[Rcpp page](http://dirk.eddelbuettel.com/code/rcpp.html). |
| 20 | + |
| 21 | +Conversion from C++ to R and back is driven by the templates `Rcpp::wrap` |
| 22 | +and `Rcpp::as` which are highly flexible and extensible, as documented |
| 23 | +in the [Rcpp-extending](http://cran.r-project.org/web/packages/Rcpp/vignettes/Rcpp-extending.pdf) vignette. |
| 24 | + |
| 25 | +Rcpp also provides Rcpp modules, a framework that allows exposing |
| 26 | +C++ functions and classes to the R level. The [Rcpp-modules]((http://cran.r-project.org/web/packages/Rcpp/vignettes/Rcpp-modules.pdf) vignette |
| 27 | +details the current set of features of Rcpp-modules. |
| 28 | + |
| 29 | +Rcpp includes a concept called Rcpp sugar that brings many R functions |
| 30 | +into C++. Sugar takes advantage of lazy evaluation and expression templates |
| 31 | +to achieve great performance while exposing a syntax that is much nicer |
| 32 | +to use than the equivalent low-level loop code. The [Rcpp-sugar]((http://cran.r-project.org/web/packages/Rcpp/vignettes/Rcpp-sugar.pdf) |
| 33 | +gives an overview of the feature. |
| 34 | + |
| 35 | +Rcpp attributes provide a high-level syntax for declaring C++ |
| 36 | +functions as callable from R and automatically generating the code |
| 37 | +required to invoke them. Attributes are intended to facilitate both |
| 38 | +interactive use of C++ within R sessions as well as to support R |
| 39 | +package development. Attributes are built on top of Rcpp modules and |
| 40 | +their implementation is based on previous work in the inline package. |
| 41 | +See the [Rcpp-atttributes]((http://cran.r-project.org/web/packages/Rcpp/vignettes/Rcpp-attributes.pdf) vignettes for more details. |
| 42 | + |
| 43 | +Many examples are included, and over 800 unit tests in over 400 unit |
| 44 | +test functions provide additional usage examples. |
| 45 | + |
| 46 | +An earlier version of Rcpp, containing what we now call the 'classic Rcpp |
| 47 | +API' was written during 2005 and 2006 by Dominick Samperi. This code has |
| 48 | +been factored out of Rcpp into the package RcppClassic, and it is still |
| 49 | +available for code relying on the older interface. New development should |
| 50 | +always use this Rcpp package instead. |
| 51 | + |
| 52 | +Additional documentation is available via the [JSS paper](http://www.jstatsoft.org/v40/i08/) by Eddelbuettel and |
| 53 | +Francois (2011, JSS) paper and the [book](http://www.rcpp.org/book) by Eddelbuettel (2013, Springer); |
| 54 | +see 'citation("Rcpp")' for details. |
0 commit comments