R and the Tidyverse

An alternative analysis language with first-class statistics and the tidyverse for readable data pipelines.

Beginner · about 15 hours · difficulty 2/5

R was built by statisticians for data analysis. It is common in academia, healthcare, pharma, public policy and some finance teams. If your target employers use R, it is an equally valid first language; otherwise Python has the broader job market.

Why people love R

  • Tidyverse: a consistent set of packages. dplyr for manipulation (filter, select, mutate, group_by, summarise), tidyr for reshaping, readr for import, ggplot2 for graphics.
  • The pipe (|> or %>%) chains steps into readable pipelines.
  • ggplot2 is one of the best static plotting systems in any language, based on the grammar of graphics.
  • Statistics built in: lm, glm, t.test and thousands of CRAN packages for specialised methods.
  • Quarto / R Markdown: combine code, output and prose into reports and slides.

Getting started

Install R and the RStudio (Posit) IDE, then install.packages("tidyverse"). Work through the free book R for Data Science.

Choosing

Pick one language and go deep before learning the other. Concepts (tidy data, grouping, joins, plotting grammar) transfer directly, so switching later is not wasted effort.

Pitfall: mixing base R and tidyverse styles randomly while learning. Stick to tidyverse at first. Move on when you can import, clean, summarise and plot a dataset with a single readable pipeline.

Key concepts

  • R and RStudio setup
  • Vectors and data frames
  • dplyr verbs
  • tidyr reshaping
  • ggplot2
  • Pipes
  • Quarto and R Markdown reports

Other options for this step

  • Python for Analysts: The Python you actually need for analysis: types, collections, control flow, functions, files and packages.

Mini project

Using the palmerpenguins dataset in R, produce a Quarto report that summarises body mass by species and sex and includes two ggplot2 charts.

Check yourself

What does group_by followed by summarise produce, and how is it similar to SQL GROUP BY?

Free resources