Skip to main content

Introduction to R and the tidyverse

tutorial
R
A concise overview of the modern R ecosystem for preparing, visualizing, and analyzing survey data.
Published

October 15, 2025

Why R for survey work?

R was built for statistical computing and reproducible reporting. For survey data, its ecosystem covers the whole chain. decoupage, svyplan, sondage, and samplyr serve the sampling frame and the draw, robotoolbox the collection with KoboToolbox, and survey and srvyr the weighted estimation.

The tidyverse in brief

The tidyverse brings together packages sharing a consistent tabular grammar built around data frames (tibble) and the native pipe |>. Everyday survey preparation relies mainly on readr for import, dplyr for filtering and aggregation, tidyr for reshaping, and ggplot2 for visualization.

Quick example

The example below reads a table, computes a mean by region, and plots a bar chart. The file household_survey.csv is an example name, to replace with your own data.

library(dplyr)
library(ggplot2)
library(readr)

survey_data <- read_csv("household_survey.csv")

survey_data |>
  filter(year >= 2024) |>
  group_by(region) |>
  summarise(average = mean(value, na.rm = TRUE)) |>
  ggplot(aes(x = region, y = average)) +
  geom_col(fill = "#3d5b8c") +
  theme_minimal() +
  labs(
    title = "Average value by region",
    x = "Region",
    y = "Average"
  )