Course · Beginner · Foundations
R and the Tidyverse for Programme Data
The same ground as the Python course, in R — projects and renv, readr and haven, the dplyr verbs, forcats and tidyr — taught on survey and registry exports, with the defaults that differ from pandas named rather than glossed.
What you will be able to do
- Set up an R project that reopens a year later on a different machine, with its package versions recorded and no absolute path in the code
- Read CSV, Excel, Stata and SPSS exports without losing a leading zero, a date or a value label, and say what each reader does with a missing-value code
- Use the dplyr verbs deliberately, and explain what group_by() and summarise() do to missing keys, unused levels and the grouping that survives the call
- Order categories with forcats so a table and a chart read the way the report needs rather than alphabetically
- Reshape a flattened repeat group with pivot_longer(), and wrap the whole cleaning in a function that runs unchanged on next quarter's export
Standards and methodologies
This is an R course, not an analysis course. It assumes you already know what an indicator is and why a denominator matters — Data Analysis Foundations teaches that — and spends its time on the language: what the tidyverse verbs actually do, which of R’s defaults will surprise you, and how to write something that still runs when you are not there.
R only. Its sibling, Python for Programme Data, covers the same ground in Python. Elsewhere on this platform every technique is shown in both languages; here the split is the point, because a team usually inherits one codebase rather than choosing between two.
If you have read the Python course, the most useful thing this one does is name
the places where R’s default is the opposite of pandas’. A missing value
makes mean() return NA instead of being skipped. A missing group key becomes
its own group instead of vanishing. An unused factor level survives instead of
being dropped. None of those are better or worse; each is a different bet about
what silence should mean, and knowing which bet you are inside is most of the
job.
Everything runs against real platform datasets — the MUAC screening register from twelve communes in Artibonite, a DHIS2-shaped vaccination extract, a WASH household survey — with the leading zeros, sentinel codes and inconsistent coding those files actually carry.
Practice
Reading the lessons is not the same as having done the work. Each of these applies the course to a dataset it did not teach on.
- Lab · 90 minThree districts, six spellingsA WASH survey where one enumerator team wrote a district name four ways, splitting the worst-performing district into fragments. Normalise it with forcats, put every household on the JMP ladders, and wrap the whole thing in a function that runs on the next round.
- Exercise · 40 minThe grouping that lingersFour dplyr pipelines, each returning a plausible number that answers a different question from the one asked. Find the leftover grouping, say what each actually computed, and rewrite it.
Progress
Take it offline
The whole course as a typeset PDF — every lesson, every code example, the data dictionary and the indicator definitions. Generated from the same source as this page.
The LaTeX source ships alongside each PDF, so an organisation can rebrand the handout or fold a lesson into its own training pack.