Introduction to R and Rstudio

Lecturer: Peter Gruber.

Modality: Online

Preliminary workshop: 10 - 11 August 2023

This two-day workshop is free of charge for participants of regular workshops (in week 1 or 2) or can be booked by itself for a fee (200 CHF).


Course Contents and Objectives

This module is an introduction to the programming language R for students with little or no experience in this language. The goal is to provide the minimal computational foundations for using R in the specialized courses of the Summer School in Social Science Methods.

After this course, students will be able to set up the Rstudio environment and to use the R language for importing, cleaning, organising and merging datasets. They will be able to calculate descriptive statistics and perform basic regression analysis and visualization tasks. They will understand the structure of the R language to be to use R in the specialized courses of the Summer School in Social Science Methods.

Course Design
The course is organised as a 2-day bootcamp. Online participation will be possible. On each day, there will be seven hours of teaching:

  • two teaching units of 1.5hours in the morning
  • two teaching units of 1.5hours in the afternoon
  • one exercise unit of 1 hour late in the afternoon
  • Students are expected to complete an online tutorial in the week before the beginning of this bootcamp on their individual schedules.

The teaching methodology will be based on realistic data sets and take students from theory to mastery in four steps:

  1. Lecture with presentation of new concepts
  2. Guided tour of R: students and professor work together on applying the new concept
  3. Short rationalisation of the lessons learned using R
  4. Individual exercises with the possibility to ask questions

There is no exam and no grade.

Class material
All slides, sample programs, sample datasets and solutions to exercises will be made available digitally.

Detailed Lecture plan
1. Getting started and getting organised
    The Rstudio environment, the logic behind R, first steps with R, variables, operators
2. Importing and organising data
    File formats, R data.frames and other data structures, the commands, summary statistics
3. Extending R
    How to use functions and how to install packages for data import via APIs
4. Spreading the word
    Simple graphs, how to create a report in Rmarkdown and how to publish it on the web
5. Working with data
    Subsetting, partitioning, merging and aggregating; applying a function by partition
6. True or false
    Formulating conditions via logical operators and logical variables
7. Simple linear models
    A simple linear regression model: set up, results, interpretation.



Students should have basic computer and statistics skills. No programming experience is required. Students are expected to bring their laptop with R and Rstudio installed. (Upon request there will be a remote session on how to install the software approx. 2 weeks before the bootcamp).