R Resources for Beginners and Intermediate Users

6 minute read


I was lucky enough to get started with R before the start of my PhD. I’d used it regularly during my year at IDinsight, which made it a lot easier to get through the first semester (we used R mostly for our applied statistics course).

If you’ve never used R and are starting a PhD in a social science in a few months, or planning to apply to a PhD, going through some of the tutorials and resources below would be a great way to spend some of your time.

Here is a list of free resources to learn R that may be useful for people getting started. I’ll try to keep this page updated as I come across more resources. Send helpful links my way on Twitter or in the comments of this post, and I’ll add them if they complement what’s already here.

First steps with R

If you are a first-time R user, thee first book below will also guide you through the pieces of software (R and RStudio) needed to work with R.

Screenshot of the RStudio Interface
The RStudio Interface
  • Hands-On Programming with R: a very helpful book, available for free online, introducing the basics of R programming. It doesn’t teach you how to manipulate, analyze, or visualize data, but it guides you through R object types, subsetting, loops, functions, etc. It entirely uses base R (the set of functions that come with the packages deployed with R by default).

  • R for Data Science (r4ds): one of the best introductions to working with data in R (also available for free online). This book teaches you the basic of data manipulation (wrangling), visualization, and analysis. It uses code from the tidyverse (a set of packages designed to work together, primarily with tidy datasets, in which each row is an observation and is column is a variable). As I mention below, r4ds users form a community that is a great source of support to learn R. The book was authored by Hadley Wickham, who is a big name in the R community: he has created the tidyverse and is Chief Scientist at RStudio.

Data visualization with R

  • ggplot (chapter 3 of r4ds): ggplot is my favorite tool for data visualization. It uses an intuitive framework called the grammar of graphics (‘gg’ in ‘ggplot’). The best introduction to ggplot is in chapter 3 of the book r4ds mentioned above, which introduces both the logic of the grammar of graphics and the functions used.

  • Thomas Lin Pedersen’s ggplot workshop (part 1 and part 2): this is an amazing way to spend 4 hours to better understand ggplot and the grammar of graphics. Thomas Lin Pedersen is also a pretty big name: he has created or maintained some of the main tidyverse packages and makes cool generative art with R.

  • The R Graph Gallery: this website is a great source of inspiration for cool data visualizations. It guides through the code required to make a wide variety of plots with R, alternatively using base R, the tidyverse, and alternative packages. It also explains how to animate your plots and make your plots interactive.

Example of an interactive map made with R

R Workflows

  • R Markdown (chapter 27 of r4ds): R Markdown provides an easy way to produce formatted PDF or HTML that include both your code and its output. The logic of R Markdown is to facilitate the reproducibility of your code, by alternating text explanations, code, and code outputs. It’s a way for you to communicate your work to other people, or to your future self (as you may have forgotten what you did after a few months). An extra benefit from learning R Markdown is that the same syntax can be used to write a book or publish a website (like this one) using the bookdown or blogdown packages.

  • Happy Git with R: if you’ve never heard of it before, version control is a set of systems used to track changes and find previous versions of your code. You can think of it as a combination of the ‘track changes’ tool on Microsoft Word and the ‘version history’ on Google Docs. Git is probably the most famous of such systems, and GitHub (owned by Microsoft since 2018) the most used platform offering version control with Git. Version control is definitely the best way to collaborate on projects involving R code. Happy Git with R is a book available for free online that introduces version control from RStudio and guides you through the required setup.

The GitHub 'octocat'
The GitHub 'octocat'

Building and Hosting Interactive Apps with R Shiny

Resources for Intermediate Users - Where to Look to Go Further?

  • Advanced R: another free book by Hadley Wickham. Rather than reading it cover-to-cover, it’s a good idea to go through specific chapters as you want to understand some aspect of R better (how functional programming works, how to make your code more efficient, etc.).

  • And more: R Packages to make your own packages, Blogdown (already mentioned above) to build a website or a blog with R, etc.

Send me a message on Twitter or comment on this post if you know of helpful resources to add to this list.