14.1 Understand the basics of C++ with R - Video Tutorials & Practice Problems
Video duration:
1m
Play a video:
Video transcript
<v Voiceover>Sometimes</v> when working with data, R just isn't fast enough. Fortunately Rcpp offers seamless integration with C++ code that is incredibly easy to write. In order to use Rcpp, you need a compiler on your system, whether that's GCC or Clang. Fortunately for Windows, CRAN has made this very easy. They have built a suite of tools called Rtools that allow you to develop with C++ and even Fortran in your R session. As you can see on this website, there are a number of different Rtools, and you need the correct set of Rtools to go with your version of R. As of this video recording, R 3.1.1 was the latest version, and that goes with Rtools31.exe. You can download this file and install it like any other Windows application, just be sure to install it in a folder that has no spaces in its name. For instance, on my computer, I have on my C drive Rtools, and within there I have different versions of Rtools. Rtools30, Rtools31. When you install Rtools it tells you to put its location in your path before anything else, but if you're working with RStudio you can ignore that and don't even put it in the path. RStudio figures out the location of the compilers automatically. If you have the compiler installed in the necessary Rtools of your own Windows, You should go ahead and install Rcpp. It will say "require Rcpp." And now you are ready to start working with C++ code.