Learning R for Software Engineers

  Hadley Wickham

A couple of weeks ago, one of the Software Engineers at RStudio asked what I’d recommend for learning R, and the education team thought it might be useful to share more widely on this blog. This is my advice for quickly picking up R if you’re already familiar with another programming language.

Work through the first few chapters of R for Data Science (R4DS) to get a sense of what R and data analysis feels like:

Attempt to ignore any feelings about how weird the language is and focus on getting a sense of the exploratory process of “playing” with data, rapidly asking, and then attempting to answer questions that you might have. To make sure you’re prepared to work with your own data, skim the vroom docs, and learn about tidy data so you have a sense for how to organise your data most effectively (although you may want to use the new pivot_() function instead of spread() and gather(): https://tidyr.tidyverse.org/articles/pivot.html).

By this point, your curiosity about R as a programming language has probably grown to an almost unmanageable level, so I’d recommend reading about copy-on-modify and the lazy evaluation of function arguments. It’s probably also worth familiarising yourself with the basic data structures and the basics of subsetting, which are particularly important in R.

I’d then pivot back to R4DS, and tactically read the chapters about the data types ( strings, factors, date-times, etc.) that you’re working with.

If you’ve mostly worked in object-oriented programming languages, I’d recommend reading the chapter on functionals in Advanced R; if you’re already familiar with functional programming, just skim the purrr docs. R uses a style of OOP that’s different to most other programming languages, so also read the intro chaapter to get some sense of the differences.

Hopefully, this now gives you a sense for how people use R and some of the things that make it different as a programming language.