Rcpp Workshop at UMBC

workshop
Published

August 7, 2017

Note

Please note that the workshop date has been moved from Friday Sept 8, 2017 to Friday Sept 22, 2017. See below for details.

Iris Gauran and I are planning to give a half-day workshop on Rcpp at UMBC. Tentative details are given below. Part of the workshop will be a “quick start”, where we will demonstrate accessing C++ code from R via toy examples. Attendees are encouraged to prepare their laptops for Rcpp programming, and bring them to the workshop to follow along with this portion.

We will focus on Rcpp programming in RStudio, which provides a common interface across all major platforms (Windows, Mac, and Linux), and helps to automate some procedural tasks.

  1. Install R (http://www.r-project.org). The current version as of this writing is 3.4.1 “Single Candle”.
  2. Install RStudio Desktop (http://www.rstudio.com). The current version is 1.0.153.
  3. Install the Rcpp, RcppArmadillo, and RcppGSL packages.
  4. Some additional libraries may be needed to compile C++ programs on your computer. These differ depending on your operating system. See http://support.rstudio.com/hc/en-us/articles/200486498-Package-Development-Prerequisites.

This may be a good time to upgrade if you have older versions of R, RStudio, or any of the listed packages.

To test your Rcpp environment, try the following in RStudio.

  1. Select File => New File => C++ File from the main menu. This will create a simple Rcpp program.
  2. Save the program, say, as example.cpp.
  3. Click the Source button, which is located in the upper-right corner of the panel with the example.cpp source code. This should produce the output
R> timesTwo(42)
[1] 84

Location: University of Maryland, Baltimore County.
Room: MP 401 (Math/Stat Seminar Room).
Time: Friday Sept 22, 1 - 4:30pm.
Cost: This workshop is free for the UMBC community.
Prerequisites: intermediate knowledge in a high level language like R, Python, or Matlab. Familiarity with R and RStudio is highly recommended.
Snacks: Light refreshments (coffee and bagels) will be provided.

Abstract
R is the preferred computing environment for many statisticians, and is used both in research and applied problems. R has achieved tremendous popularity because it is free, open source, and available on all modern platforms (Windows, Mac, and Linux). The R programming language is simple and intuitive, and well-suited for fast prototyping of complicated algorithms. However, R users can often find the performance of their programs to be lacking.

This workshop will demonstrate Rcpp, an extension of R that facilitates interoperability between R and C++ (Eddelbuettel, 2013). With Rcpp, computationally intensive parts of your program can be written in C++ and seamlessly called from R, potentially giving dramatic performance improvements within the familiar R user environment. We will provide a quick start for new Rcpp users through simple examples, and also examine several larger-scale statistical applications. C++ programming is usually more burdensome than R programming, so we will discuss tradeoffs between optimizing R code and migrating to C++, and ways to minimize suffering while making the transition.

References