Preparation Course

In this course we will be using R and RStudio. We ask you to install and/or update these programs before the start of the course, so that we do not loose time once the course starts. In this chapter, we cover the course requirements and some tips on how you should change your RStudio settings.

Install or update R

If you haven’t installed R yet, do so now by getting the newest version from CRAN. If you do have R installed, check your Version of R by opening RStudio and typing the following command into the console.

R.version.string
## [1] "R version 4.3.1 (2023-06-16)"

This returns the version number of your R installation, whereas the first digit (4) indicates the number of the major release, the second digit (3) indicates the minor release and the last digit (1) refers to the patch release. As a general rule of thumb, you will want to update R if you

  • don’t have the current major version or
  • are lagging two (or more) versions behind the current minor release

In the time of writing (February, 2024), the current R Version is 4.3.2 (released on 31.10.2023, see cran.r-project.org). Your installation should therefore not be older than 4.2.0. If it is, make sure that you have updated R before the course. Check these instructions on how to update R

Install or update RStudio

RStudio is the IDE (integrated development environment) we use in our course to interact with R. There are good alternatives you can use, RStudio simply seems to be the most popular choice. If you want to use your own IDE, please feel free to do so. However, we don’t recommend this if you are a beginner.

We recommend updating RStudio to the newest version before the course: check if this is the case by clicking on help > check for updates.

Configure RStudio

Now we will set some RStudio Global options. But first, close all instances of RStudio and restart it (!!!). Then go to Tools > Global options.

  • R General
    • Deactivate the option “Restore .RData into workspace at startup”1
    • Set “Save workspace to .RData on exit” to “Never”2
  • Code
    • Activate the option “Use native pipe operator, |> (requires R 4.1+)”
  • R Markdown
    • Deactivate the option “Show output inline for all R Markdown documents”

Click on “Ok” to apply the change and close the options menu.

Folder structure for this course

By this point, you probably have created a folder for this course somewhere on your computer. In our example, we assume this folder is located here: C:/Users/yourname/semester2/Module_DAMO (mentally replace this with your actual path). Before we dive into the exercises, take a minute to think about how you are going to structure your files in this folder. This course will take place over several weeks, and in each week you will receive or produce various files. We recommend creating a separate folder for each week, and one folder for the case studies, like so:

Course Folder (C:\\Users\\yourname\\semester2\\Module_DAMO)
 ¦--week_1                                                
 ¦--week_2                                                
 ¦--week_3                                                
 |--...                                                
 °--case_studies 

For the R-exercises we recommend that you create a new RStudio Project each week in subdirectory of the appropriate week. For example, this week your folder structure could look like this:

Folder Week 1 (C:\\Users\\yourname\\semester2\\Module_DAMO\\week_1)
 ¦--slides.pdf                                                  
 ¦--my_notes.docx                                               
 ¦--seminar_screenshot.jpg                                      
 °---damo-week1-rexercise                                             
     ¦--damo-week1-rexercise.Rproj                                   
     ¦--test.csv                                      
     °--my_solution.qmd   

Note:

  • the RStudio Project is located in a subfolder of C:/Users/yourname/semester1/Module_DAMO/week_1 and named damo-week1-rexercise.
  • damo-week1-rexercise is the project’s directory name and the project name
  • we realize that damo and the week number is redundant, there is a reason3 for this
  • this means each week is a fresh start (which has pros and cons)

Create an RStudio project for the first week

Create a new RStudio Project (File > New Project > New Directory > New Project).

  1. Click on “Browse” and switch to your equivalent of the folder C:/Users/yourname/semester1/Module_DAMO/week_1 (the project we are about to initiate will be be created in a subdirectory of this folder). Click on “open” to confirm the selection
  2. In the field “Directory name”, type damo-week1-rexercise. This will be the name of your RStudio project and it’s parent directory.
  3. Click on “Create Project”

You are all set! You can start working on the tasks of exercise 1.


  1. We recommend that you start each RStudio session with a blank slate, as recommended by Wickham, Çetinkaya-Rundel, and Grolemund (2023)↩︎

  2. If we don’t restore the workspace at startup, there is no need to save it on exit.↩︎

  3. You will see the project names of all your RStudio Projects listed in RStudio. Having the week number in the project name keeps you from getting confused on which project you are working on.↩︎