Projects in R

Information and course material for the Projects in R course of the Public Health Sciences Course Program at the University of Bern

Table of contents

  1. Preparation
  2. Timetable
  3. Slides
  4. Exercises
  5. Data sets
  6. Further online material
  7. Contact

Preparation

Mandatory steps

Course participants will bring their own laptops with installed versions of R, RStudio, and Git:

  1. Download and install R:
  • Windows: Click on "Download R for Windows", then click on "base", then click on the Download link.
  • macOS: Click on "Download R for macOS", then under "Latest release:" click on R-X.X.X-arm64.pkg or R-X.X.X-x86_64.pkg for Apple silicon (M1/M2) or older Intel Macs, respectively.
  • Linux: Click on "Download R for Linux" and choose your distribution for more information on installing R for your setup.
  1. Download and install RStudio.
  2. Install Git using the following instructions.
  3. If you don’t already have one, don't forget to create a GitHub account.

If you are new to R and RStudio, we recommend you to follow the 90-minute video tutorial Introduction to R and RStudio.

Optional steps

The following preparation steps are optional. You will also have time during the course to complete these steps.

  1. Make sure RStudio knows about Git by following the corresponding section here.
  2. Install the usethis package for R using the following command: install.packages("usethis")
  3. Set up Git using the following command: usethis::use_git_config(user.name = "Jane Doe", user.email = "jane@example.org")
  4. Generate a personal access token (PAT) and store your PAT as described in Section 9.3 and 9.4 here.

Required packages

To work on the exercises, course participants have to install the following packages:

  • usethis - Workflow package
  • gitcreds - Queries Git credentials from R
  • here - Easy file referencing
  • tidyverse - A set of packages
  • medicaldata - Medical data sets
  • cowplot - Features to create publication-quality figures

Simply type install.packages("packagename"), but RStudio will ask you about it as well if you want to load a package that you haven't installed yet.

Timetable

Day Time Topic Slides Lecturer(s)
Monday, 22 April 2024 09:00-12:00 Introduction to R, the tidyverse, and data wrangling HTML Christian Althaus, Alan Haynes
Monday, 22 April 2024 13:00-17:00 Data visualization with the tidyverse HTML Christian Althaus, Judith Bouman, Martin Wohlfender
Tuesday, 23 April 2024 09:00-12:00 Reproducibility and GitHub HTML Christian Althaus, Alan Haynes
Tuesday, 23 April 2024 13:00-17:00 Writing a reproducible report using Markdown/Quarto Christian Althaus, Alan Haynes, Judith Bouman, Martin Wohlfender

Slides

You can download all slides here. If you want to see them in your web browser, click the corresponding link in Timetable.

Exercises

You can find material for the exercises here.

Data sets

We will use the following data sets during the course:

File Description  Source Exercise
COVID19Cases_geoRegion.csv Laboratory-confirmed SARS-CoV-2 cases by region FOPH -
COVID19Cases_geoRegion_AKL10_w.csv Laboratory-confirmed SARS-CoV-2 cases by region and age group FOPH -
covid_cantons_2020_06.csv Laboratory-confirmed SARS-CoV-2 cases for selected cantons and time period FOPH -
ebola.csv World-wide Ebola cases from 2014-2016 data.world 4
insurance_with_date.csv Data on costs of medical procedures kaggle 5

Further online material

We recommend the following online tutorials and books on R and RStudio with specific applications to epidemiology, public health, and data science:

Contact

If you have any questions regarding the course, please get in touch with us at phs-info.ispm@unibe.ch or christian.althaus@unibe.ch.