Syllabus

Author

Maxime Walder

Published

September 1, 2026

Organisation du document


Summary

The class Applied Methods aims to introduce students to the use of data and statistics to answers substantial questions and provide student with a strong and practical background in the analysis and visualisation of data with R. In addition to the classical statistical approach, the class is designed to provide an fundamental transferable skill to the use of data for data-driven report and in-depth analyses with quantitative data.

The course first covers the basics of R and RStudio, on statistics and data manipulation.

Second, the course dives into the data vizualisation and the production of high quality and resolution figures.

Third, the course propose an overview on how to use APIs and web-scrapping methods to get data from the web.

Fourth, the class then turns on more complexe analyses with sessions on regression models, interaction terms, and their associated visualization.

Fifth the class then provide key technical skkils on how to use R to create data driven reports, and create interactive data leaderbord.

Finally, the course ends with a introduction to quantitative text analyses, text data pre-processing, text statistics and the visualization of text data.

Overall, this course is designed to provide a strong practical guide to use quantitative data and produce data-driven transferable knowledge.

Course description

This course provides students with a comprehensive and practical foundation in applied quantitative methods using the statistical programming language R and the integrated development environment RStudio. It is designed for students seeking to develop transferable analytical skills for data-driven research, reporting, and decision-making across disciplines.

The course follows a progressive, hands-on approach structured around real-world data applications. It begins with foundational skills in data handling and statistical reasoning, then moves toward increasingly advanced analytical techniques and forms of output. Throughout, emphasis is placed on reproducibility, clarity of interpretation, and effective communication of results.

The philosophy of the class does not build on strong statistical background but instead uses applied approach and hands on approach to statistical analyses and data representation to perform valid statistical analyses with R. As such, the class build less on this type of content:

\[ \bar{X} = \frac{1}{n}\sum_{i=1}^{n} X_i \]

Than on this type of content:

Code
x <- rnorm(100, 10, 5)

mean_x <- sum(x)/length(x)

print(mean_x)
[1] 10.13319

The idea is to enable student to think about the data and how to use R to solve practical issue with the data (changing the structure, coding data, merging data set), and perform meaningful analyses that helps understand the social reality it aims to analyse.

Teaching objectives

By the end of the course, students will be able to:

  • Develop proficiency in data manipulation, cleaning, and transformation

  • Apply core statistical concepts to real datasets

  • Produce high-quality, publication-ready data visualizations

  • Collect and manage data from external sources such as APIs and websites

  • Conduct and interpret regression models

  • Analyze complex relationships including interaction effects

  • Create reproducible, data-driven reports

  • Build interactive data visualization tools

  • Perform introductory quantitative text analysis

More broadly, the course aims to equip students with transferable analytical skills that extend beyond R, including structured problem-solving, critical interpretation of quantitative evidence, and the ability to communicate findings effectively to both technical and non-technical audiences.

Session organization and ressources

Each session strats Friday morning at 10h15 and ends at 15h with a one hour lunch breack in the middle. The session usually contain:

  • A first lecture discussion part
  • Hands on approach on coding exemples
  • Guided practical work and exercices
  • Time for independent applications
  • Wrap up and discussion

The course also provides various ressource that support students in their learning. These ressources are:

  • Slides for the lectures.
  • Session summary cheat sheet (with usefull R commands and libraries)
  • R code examples
  • Exercises in R
  • Additional resources

Evaluation

The class is graded based on two complementary types of evaluation. First, three in class assignment presented as problem sets will count for one third of the final grade. Second, students will provide group work and hand in data driven policy report with a reproducible R script, a Quarto document with the written report, a Shiny application providing an interactive visualization of their main findings and an in-class presentation of their work in progress during the two last weeks of the semester. Third, students will have an tailored oral exam on their own project. During this exam, student will be asked to answer substantive question on the interpretation of their analyses and lines of codes in their project.

Assignments

Assignment 1 - October 9

The first assignment will present students with problem sets to resolve in a R script. These problem sets will focus on data manipulation, descriptive statistics and the graphical representation of variables and relationship aond variable.

Assignment 2 - November 13

The second assignment will ask students to use R to compute regression models, including interaction terms, and include visual representation of their results and substantive interpretation of these results.

Assignment 3 - December 4

For the third assignment, students will developp a small shiny application that presents descriptive and more advanced statistics.

Group projects

The group projects are collaborative works aiming to provide reprocible data driven policy report on a delimited topics using administrative data. The goal of this project is to show that students know how to conduct quality data driven analyses, present their work in progress, provide reproducible material for their work, present their findings in a Quarto report and provide an interactive visualization of their findings.

The group project thus have four components:

Project presentation

During the two lasts sessions of the semester, students will present their work in progress in class presentation. Each group has 10 minute to present their work follow by 5 minutes of question from the audience, and 5 minutes of comments by the instructor.

Reproductible R script

Each group need to upload reproductible R script and associated folder structure so the instructor can replicate their analyses.

Quarto report

Each group is requiered to provide a Quarto document that presents their data driven report and the interpretation of their finding. They thus need to upload both a -qmd file and an .html file containing the compiled document.

Shiny application

Each group developps a small shiny application that provide an interactive presentation of their main results.

Dealine

For group projects, students need to upload all the content of their work in a .zip folder in Moodle before the 13th of January 2027 at 20h.

Oral exams

During the exam session, tailored oral examination for each student regarding their own group project will be held. For these examination, no preparation is necessary, and students will be asked to provide justification on the code, the content and the interpretation of their group project.

Grading

The grading combine the evaluation and gives each student a unique grade based on these three types of evaluations.

Session planning

Session Date Title
1 September 18 Introduction to R and RStudio
2 September 25 Data manipulation and descriptive statistics
3 October 2 Data visualization
- October 9 Dies Academic
4 October 16 Assignment 1
Writing report with Quarto
5 October 23 Hypothesis testing and introduction to regressions
6 October 30 Interpret interaction terms in statistical models
- November 6 Reading week
7 November 13 Assignment 2
Free code session on projects
8 November 20 Introduction to text as data
9 November 27 Introduction to ShinyR: Building shiny applications
10 December 4 Assignment 3
Introduction to Webscrapping
11 December 11 Group project presentations 2
Using Application Private Interfaces (API)
12 December 18 Group project presentations 3
Class synthesis

Session 1: Introduction to R and RStudio

The first session introduces the course and provides an overview of its objectives, organization, evaluation, and learning resources. Students will then become familiar with R and the RStudio integrated development environment. They will learn the basic principles of working with R, including creating objects, calling functions, using packages, writing scripts, importing data, and inspecting datasets.

The session is structured as follows:

  • Introduction to the course
  • Course content and learning objectives
  • Evaluation and assignments
  • Course resources and GitHub repository
  • Introduction to R and the RStudio IDE
  • The console, scripts, objects, and assignment
  • Functions and packages
  • Importing data into R
  • Inspecting dataset
  • In-class exercises

Additional resources

  • Hands-On Programming with R – A free introductory book written specifically for readers with no previous programming experience.
  • Posit Cheatsheets – Quick-reference sheets for RStudio, base R, data import, and tidyverse packages.
  • swirl: Learn R in R – An optional interactive course that allows students to practise R directly in the R console.
  • An Introduction to R – The official R manual; useful as a reference, although more technical than the other introductory resources.

Session 2: Data manipulation and descriptive statistics

Session 2 is devoted to preparing data for meaningful analysis. Students learn how datasets are structured, how observations and variables are defined, and how codebooks document the meaning and coding of variables. The session introduces the principal tools provided by dplyr and tidyr for selecting, filtering, transforming, recoding, summarizing, reshaping, and combining data.

Particular attention is given to administrative data, where information may be distributed across several datasets, collected at different levels of analysis, or organized according to administrative rather than analytical needs. Students also learn to identify missing values, duplicates, inconsistent categories, and unsuccessful joins.

The session is structured as follows:

  • Understanding observations, variables, values, and levels of analysis
  • Reading and using codebooks and metadata
  • Inspecting datasets
  • Selecting, filtering, arranging, and renaming variables
  • Creating and recoding variables
  • Identifying missing values and duplicate observations
  • Producing descriptive statistics
  • Reshaping data
  • Understanding identifiers and merging datasets
  • Checking whether a data transformation produced the expected result
  • Guided exercise using Swiss or Geneva administrative data (OCSTAT & OFS)

Additional resources

Session 3: Data visualization

Session 3 introduces data visualization as both an analytical and communication tool. Students learn to use ggplot2 and its layered grammar of graphics to explore distributions, compare groups, and represent relationships between variables.

The session distinguishes exploratory graphics, which help analysts understand their data, from explanatory graphics, which communicate a finding to a particular audience. Students learn how to select an appropriate graphical representation, improve labels and visual appearance, and avoid misleading data representations.

The session is structured as follows:

  • Data vizualisation and data communication
  • Exploratory versus explanatory visualization
  • The grammar of graphics: data, aesthetic mappings, geometries, and layers
  • Visualizing categorical variables with bar charts
  • Visualizing numerical variables with histograms and density plots
  • Comparing groups with boxplots, colors, and facets
  • Visualizing relationships with scatterplots and fitted lines
  • Using scales, labels, legends, annotations, and themes
  • Choosing accessible and meaningful color palettes
  • Identifying misleading or ineffective visualizations
  • Exporting high-resolution figures
  • Guided exercise using public expenditure, population, transport, or service-delivery data

At the end of the session, you should be able to produce plots as shown bellow

Code
library(dplyr)

Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
Code
library(RSwissPos)
Loading required package: pxR
Loading required package: stringr
Loading required package: reshape2
Loading required package: jsonlite
Loading required package: plyr
------------------------------------------------------------------------------
You have loaded plyr after dplyr - this is likely to cause problems.
If you need functions from both plyr and dplyr, please load plyr first, then dplyr:
library(plyr); library(dplyr)
------------------------------------------------------------------------------

Attaching package: 'plyr'
The following objects are masked from 'package:dplyr':

    arrange, count, desc, failwith, id, mutate, rename, summarise,
    summarize
Loading required package: rjson

Attaching package: 'rjson'
The following objects are masked from 'package:jsonlite':

    fromJSON, toJSON
Code
library(ggplot2)
library(ggpubr)

Attaching package: 'ggpubr'
The following object is masked from 'package:plyr':

    mutate
Code
data <- getSwissvotes()
Please cite: Swissvotes (Year). Swissvotes – die Datenbank der eidgenössischen Volksabstimmungen. 
Code
data <- data %>% 
  mutate(gov_support = ifelse(br.pos==1, as.numeric(volkja.proz),
                              ifelse(br.pos==2, 100 - as.numeric(volkja.proz), NA)),
        date= as.Date(datum, "%d.%m.%Y"))

fig <- ggarrange(
  ggplot(data[data$rechtsform!=5,])+
    geom_bar(aes(x=rechtsform), width=.3, color = "black", fill = "darkblue", alpha = .3)+
    scale_x_continuous(breaks = c(1,2,3,4), 
                       labels = c("Mandatory referendums","Facultative referendums", "Initiative", "Counter proposals"))+
    xlab("Institution type")+
    labs(title = "Number of allot by institutional type",
         subtitle = "Example of a bar plot")+
    ylab("N")+
    theme_minimal(),
  
  ggplot(data)+
    geom_histogram(aes(x=gov_support), color = "black", fill = "lightgrey")+
    geom_density(aes(x=gov_support))+
    xlab("% of support for the government position")+
    ylab("N")+
    labs(title = "Share of support for the government's position",
         subtitle = "Example of an historam with density line.")+
    theme_minimal(),
  
  ggplot(data)+
    geom_point(aes(x=date, y=gov_support))+
    geom_smooth(aes(x=date, y=gov_support), method="lm", color = "grey", fill="lightblue")+
    theme_minimal()+
    labs(title = "Evolution of support for the government's position",
         subtitle = "Example of scatter plot with regression line")+
    xlab("Date")+
    ylab("% of support for the government position"),
  
  ggplot(data[data$rechtsform!=5,])+
    geom_boxplot(aes(x=as.factor(rechtsform), y=gov_support))+
    scale_x_discrete(breaks = c(1,2,3,4), 
                       labels = c("Mandatory referendums","Facultative referendums", "Initiative", "Counter proposals"))+
    xlab("Institution type")+
    labs(title = "Share of support for the government's position \n by institution type",
         subtitle = "Example of a cross categorical boxplot")+
    ylab("% of support for the government position")+
    theme_minimal(), 
  nrow=4, ncol=1
  
    
    
)
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
Warning: Removed 146 rows containing non-finite outside the scale range
(`stat_bin()`).
Warning: Removed 146 rows containing non-finite outside the scale range
(`stat_density()`).
`geom_smooth()` using formula = 'y ~ x'
Warning: Removed 146 rows containing non-finite outside the scale range
(`stat_smooth()`).
Warning: Removed 146 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 142 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Code
fig

Additional resources

Session 4: Assignment 1, and Writing reports with Quarto

The first part of Session 4 is devoted to Assignment 1. Students complete a series of problems involving data inspection, manipulation, descriptive statistics, and visualization. The assignment assesses their ability to navigate an unfamiliar dataset and use R to answer clearly defined analytical questions.

The second part introduces Quarto as a system for combining written analysis, R code, tables, and figures in a reproducible report. Students create and render a short report in which results are generated directly from the underlying code.

The session is structured as follows:

  • Presentation of Assignment 1 instructions and data
  • Individual completion of Assignment 1
  • Submission and technical checks
  • Introduction to reproducible reporting
  • Structure of a Quarto document
  • Writing formatted text with Markdown
  • Creating and configuring executable R code chunks
  • Displaying and hiding code, messages, and warnings
  • Using inline R code to report calculated values
  • Adding tables, figures, captions, and cross-references
  • Adding references and bibliographic information
  • Rendering and troubleshooting a Quarto report
  • Guided exercise producing a short data-driven policy brief

Additional resources

Session 5: Hypothesis testing and introduction to regression

Session 5 introduces statistical inference through practical policy questions. Students learn how analysts move from describing observed data to assessing whether an observed difference or relationship is compatible with random variation.

The session introduces hypotheses, confidence intervals, p-values, and common forms of statistical error without relying heavily on mathematical derivations. It then presents simple linear regression as a way to summarize and analyze the relationship between an outcome and an explanatory variable. Emphasis is placed on substantive interpretation and on the distinction between statistical association and causation.

The session is structured as follows:

  • From descriptive analysis to statistical inference
  • Central aspect of probability theory
  • Samples, populations, estimates, and uncertainty
  • Formulating null and alternative hypotheses
  • Understanding test statistics and p-values
  • Confidence intervals and statistical uncertainty
  • Type I and Type II errors
  • Comparing group means and testing correlations in R
  • Introduction to simple linear regression
  • Outcome and explanatory variables
  • Estimating a model with lm()
  • Interpreting the intercept and slope coefficients
  • Visualize regression results - Coeficient and effect plots
  • In class exercice - Linking theoretical and empirical modeling

Additional resources

Session 6: Interaction terms in statistical models

Session 6 extends linear regression to relationships that vary across groups or contexts. Students learn that the association between an explanatory variable and an outcome may depend on a third variable. These conditional relationships are represented using interaction terms.

Because interaction coefficients can be difficult to interpret directly, the session emphasizes predictions and visualization. Students compare additive and interactive models, calculate predicted outcomes for meaningful combinations of variables, and communicate the resulting patterns in substantive language.

The session is structured as follows:

  • Review of simple and multiple linear regression
  • Control variables and conditional associations
  • The substantive meaning of moderation and heterogeneity
  • Additive models versus interaction models
  • Modeling an interaction in R
  • Interactions between numerical and categorical variables
  • Interactions between two categorical variables
  • Interactions between two numerical variables
  • Interpreting conditional coefficients
  • Calculating predicted outcomes
  • Calculating and interpreting conditional slopes
  • Visualizing interactions and their uncertainty
  • Common interpretation errors
  • Guided exercise examining heterogeneous policy outcomes across groups or municipalities

Additional resources

  • Model to Meaning: Predictions – Explains how fitted models can be translated into substantively meaningful predicted outcomes.
  • broom Documentation – Reference for extracting regression coefficients, model statistics, fitted values, and residuals.

Session 7: Assignment 2 and Application Programming Interface

The first part of Session 7 is devoted to Assignment 2. Students estimate and interpret regression models, including interaction terms, and communicate their findings through tables, visualizations, and substantive written interpretations.

The second part introduces Application Programming Interfaces, or APIs. Students learn how APIs provide structured and reproducible access to data made available by public institutions. They examine endpoints, parameters, requests, responses, status codes, and JSON data before using R to retrieve and transform data from a public API.

The session is structured as follows:

  • Presentation of Assignment 2 instructions and data
  • Individual completion of Assignment 2
  • Submission and technical checks
  • Review of group project requirements
  • Formulating a precise and answerable policy question
  • Identifying outcomes, explanatory variables, and units of analysis
  • Reviewing data availability, quality, and limitations
  • Creating a reproducible folder structure
  • Separating raw data, processed data, scripts, figures, and outputs
  • Developing a preliminary analysis plan
  • Dividing responsibilities within groups
  • Independent group coding with instructor support
  • End-of-session progress check and definition of next steps

Additional resources

  • opendata.swiss – Central catalogue for open data produced by the Confederation, cantons, communes, and other public organizations.
  • PXWeb API Interface for R – Guide to accessing statistical-agency databases through PXWeb APIs.

Additional resources

Session 8: Introduction to text as data

Session 8 introduces written documents as a source of quantitative data. Students learn how administrative reports, parliamentary debates, consultation responses, policy documents, and other textual materials can be transformed into structured datasets.

The session presents the principal stages of a quantitative text-analysis workflow: importing documents, cleaning text, tokenizing documents, removing non-informative terms, counting words, comparing documents, and visualizing textual patterns. Particular attention is paid to the analytical consequences of preprocessing decisions and to the limitations of automated interpretation.

The session is structured as follows:

  • Text as a source of administrative and policy data
  • Defining documents, corpora, tokens, and features
  • Importing text and retaining document metadata
  • Character encoding and multilingual text
  • Basic string manipulation
  • Tokenizing documents into words
  • Lowercasing and removing punctuation, numbers, and stop words
  • Stemming and lemmatization
  • Creating a document-feature matrix
  • Calculating word and document frequencies
  • Identifying distinctive words with TF-IDF
  • Comparing language across agencies, groups, or periods
  • Visualizing text frequencies and document differences
  • Introduction to dictionary and sentiment approaches
  • Validity, context, and limitations of automated text analysis
  • Guided exercise using administrative or parliamentary documents

Additional resources

Session 9: Introduction to Shiny for R

Session 9 introduces Shiny as a framework for transforming an R analysis into an interactive web application. Students learn how an application can allow users to filter data, choose indicators, explore results, and generate customized visualizations without directly interacting with the underlying code.

The session focuses on the basic architecture of a Shiny application: the user interface, the server function, inputs, outputs, and reactive relationships. Students progressively transform a static visualization into a small interactive public-data dashboard.

The session is structured as follows:

  • The purpose and possible uses of interactive applications
  • Examples of Shiny applications in research and public administration
  • Structure of an app.R file
  • The user interface and server components
  • Creating inputs with menus, buttons, sliders, and checkboxes
  • Creating text, table, and graphical outputs
  • Connecting inputs and outputs
  • Understanding reactive programming
  • Using reactive expressions
  • Filtering data based on user selections
  • Producing reactive ggplot2 visualizations
  • Organizing an application with sidebars, cards, and tabs
  • Managing files and data inside an application
  • Validating user input and handling missing selections
  • Running and debugging an application
  • Guided exercise building an interactive public-data explorer

Additional resources

Session 10: Assignment 3 and Introduction to web scraping

The first part of Session 10 is devoted to Assignment 3. Students develop a small Shiny application that presents descriptive statistics, model results, or interactive visualizations based on a supplied dataset.

The second part introduces web scraping as a method for collecting structured information from web pages when a direct download or API is not available. Students learn the elementary structure of HTML documents, the role of CSS selectors, and the use of rvest to extract text, links, and tables.

The session also addresses responsible data collection. Students are expected to consult website terms of use, respect access restrictions, limit the frequency of requests, and avoid collecting personal or sensitive information.

The session is structured as follows:

  • Presentation of Assignment 3 instructions and data
  • Individual development of a small Shiny application
  • Submission and technical checks
  • Web pages as potential sources of public data
  • Difference between downloads, APIs, and web scraping
  • Introduction to HTML elements and attributes
  • Introduction to CSS selectors
  • Inspecting the structure of a web page
  • Downloading HTML with read_html()
  • Selecting elements with html_elements()
  • Extracting text, attributes, links, and tables
  • Converting extracted information into a data frame
  • Cleaning and validating scraped data
  • Introduction to scraping multiple pages
  • Static versus dynamically generated web pages
  • Legal, ethical, and technical limitations
  • Guided exercise using a public institutional website

Additional resources

Session 11: Group project presentations I and Project coding workshop I

Using Application Programming Interfaces {#sec16}

The first part of Session 11 is devoted to group project presentations. Groups present their research question, data, analytical strategy, preliminary results, and the planned structure of their Quarto report and Shiny application. The presentations provide an opportunity to receive feedback before the final submission.

The remainder of the session is organized as a project coding workshop. Student groups work on their data-driven policy projects with support from the instructor.

The session is structured as follows:

  • Group project presentations
  • Project coding workshop

Session 12: Group project presentations II and Project coding workshop II

The final session completes the group project presentations and provides a synthesis of the course. Students review the complete data-analysis workflow, from formulating a policy question and obtaining data to cleaning, analysis, visualization, and communication.

The remainder of the session is organized as a project coding workshop. Student groups work on their data-driven policy projects with support from the instructor. At the end of the session, we will review the scope o the oral examinaion and conclude the class with students feedbacks.

The session is structured as follows:

  • Group project presentations
  • Project coding workshop
  • Scope of the individual oral examination
  • Course conclusion and directions for further learning

Additional resources