Tutorial by Examples

Rcpp features two functions that enable code compilation inline and exportation directly into R: cppFunction() and evalCpp(). A third function called sourceCpp() exists to read in C++ code in a separate file though can be used akin to cppFunction(). Below is an example of compiling a C++ function w...
Rcpp Attributes makes the process of working with R and C++ straightforward. The form of attributes take: // [[Rcpp::attribute]] The use of attributes is typically associated with: // [[Rcpp::export]] that is placed directly above a declared function header when reading in a C++ file via sou...
Within C++, one can set different compilation flags using: // [[Rcpp::plugins(name)]] List of the built-in plugins: // built-in C++11 plugin // [[Rcpp::plugins(cpp11)]] // built-in C++11 plugin for older g++ compiler // [[Rcpp::plugins(cpp0x)]] // built-in C++14 plugin for C++14 standa...
To use additional packages within the Rcpp ecosystem, the correct header file may not be Rcpp.h but Rcpp<PACKAGE>.h (as e.g. for RcppArmadillo). It typically needs to be imported and then the dependency is stated within // [[Rcpp::depends(Rcpp<PACKAGE>)]] Examples: // Use the RcppAr...

Page 1 of 1