Introduction to programming for data analysis

Authors
Affiliation

AMSE, Aix Marseille University

AMSE, Aix Marseille University

AMSE, Aix Marseille University

AMSE, Aix Marseille University

You are on the page for the Introduction to programming for data analysis course, taught at level M2 (first year of Master degree) at Aix Marseille School of Economics (Faculty of Economics and Management at Aix-Marseille University).

This course introduces the basics of programming for data analysis, using the R language. Over four 3-hour sessions, students learn to find, import, clean, combine, and visualize data, and to run their first statistical tests and regressions. This course aims at providing students with thepractical foundation needed to conduct an independent empirical project.

Acknowledgement

The first version of this course was created by Pierre Michel and Morgan Raux, who kindly shared their teaching materials.

The creation of the current documents was assisted with Gemini Flash, Chat GPT-5 and Claude Sonnet 5.

Slides

Session Slides PDF
1 – Data Management
2 – Data Wrangling
3 – Data Visualization
4 – Statistical Analysis

Tutorials (practice at home)

Tutorial Web PDF
Tutorial 1 – Data Management and Data Wrangling
Tutorial 2 – Data Visualization and Summary Statistics
Tutorial 3 – Linear Regressions and Statistical Tests

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

  • Organize a data analysis project following good coding practices (file structure, naming conventions, relative paths).
  • Find, import, and combine data from multiple sources.
  • Clean and validate a dataset (completeness, validity, consistency).
  • Produce basic summary statistics and visualizations using {dplyr} and {ggplot2}.
  • Implement and interpret basic statistical tests and linear regressions.

0.1 Session 1 — Data Management

File paths (absolute vs. relative), .R scripts, project organization, the R/RStudio environment, and an introduction to data analysis concepts (units of observation, sources of variation, cross-sectional vs. panel data).

Session 2 — Data Wrangling

Finding and combining data sources, functions/libraries/loops in R, importing and exporting data, data quality indicators, and joining datasets with {dplyr}.

Session 3 — Data Visualization

The grammar of graphics with {ggplot2}: aesthetics, common chart types, labels, scales, facetting, and exporting graphs.

Session 4 — Statistical Analysis

Statistical hypothesis tests, linear regression, visualizing predicted values, regression with categorical features and interaction terms, non-linear terms, and regression with panel data.

Application

Across the four sessions, students apply each new tool to a running example built from Eurostat and IPEDS/labor-force data, moving progressively from raw data to a small empirical analysis.

Practical Aspects

  • Format: 4 sessions x 3 hours
  • Language: R (using RStudio)
  • Level: Master 1, Economics, no prior programming experience required

Evaluation

The course is assessed through a take-home assignment: students conduct a small data project of their own, finding data and carrying out an empirical analysis to answer a provided questionnaire. Students are guided throughout the sessions, so that limited additional work is required outside of class.

Main reference

Wickham, H., Cetinkaya-Rundel, M., Grolemund, G. (2023). R for Data Science: Import, Tidy, Transform, Visualize, and Model Data. O’Reilly Media. 🌐 https://r4ds.hadley.nz/

Software

You need to install both R (the statistical programming language) and Rstudio (the application/interface in which you will work with R).

  1. Download and install the latest version of R.

    Mac users: You first need to determine whether your Mac has an Apple silicon processor (M1, M2, M3, M4, etc.) or an Intel processor.

    • Click the Apple menu in the top-left corner of your screen.
    • Select About This Mac.
    • Look for Chip (on newer Macs) or Processor (on older Macs).

    If you see:

    • “Apple M1”, “Apple M2”, “Apple M3”, “Apple M4”, etc. → you have an Apple silicon Mac. Download the R installer ending in -arm64.pkg.
    • “Intel” → you have an Intel Mac. Download the R installer ending in -x86_64.pkg.

    Windows users: Download the Windows version of R.

    Linux users: Download the appropriate version for your Linux distribution.

  2. Download and install RStudio Desktop.

    RStudio is a program that provides an interface for working with R. You need to install R first, and then install RStudio.

    For most students, simply download the current version of RStudio Desktop for your operating system.

    If you have an older version of Windows or macOS and the current RStudio version does not support your operating system, scroll down on the RStudio download page and select an older version compatible with your operating system.

    Linux users: Select the RStudio version appropriate for your Linux distribution.

Github Repository

View on GitHub

List of Contributors

As mentioned above, the first version of this course was created by Pierre Michel and Morgan Raux.

Since then Ulrich Aiounou and I updated the content.