Guru's Verification engine ensures consistency, confidence, and trust in the knowledge your organization shares. Learn more.

R | Calling C++ from R

One way to significantly improve the performance of R code is to replace the most frequently used and/or time-consuming parts of the code (determined via performance profiling [1]) with equivalent C++ code, which is typically much faster.

It is very easy to use C++ code in R, which has a couple of packages to facilitate this: Rcpp [2] and cpp11 [3]. These two largely do the same job (though they can be used side-by-side). The main differences are:

  • Rcpp is older and more established, and has more advanced features than cpp11, which is more streamlined

  • cpp11 has support for the ALTREP framework [4], which Rcpp does not

More information on how to use these, see [5] and [6] respectively.

Resources:

You must have Author or Collection Owner permission to create Guru Cards. Contact your team's Guru admins to use this template.