Workshop 9: Lines, Scales, Labels, and Themes

Giulia Rathmes

2022-12-06

1 Intro

Welcome!

For this workshop, we have two activities. You will be completing Activity 1 in this Rmd.

The assignment should be submitted individually, but you are encouraged to brainstorm with partners.

The final due date for Activity 1 is Tuesday, December 6th at 23:59 PM UTC+2.

2 Instructions

Your assignment for Activity 1 is to recreate a plot from the EpiGraphHub COVID-19 Switzerland dashboard in R using {ggplot2}.

  1. First choose one of the four line graphs shown on the dashboard. This is the one you will recreate.

  2. Download the data associated with your chosen plot by clicking the three dots on the top right on the plot and selecting “Export CSV”

  3. Once downloaded, move the CSV to the “data” folder of this R project.

3 Prepare the data

Now, read the dataset into R. Remember to use the here() function to allow your Rmd to use project-relative paths.

## Rows: 1010 Columns: 5
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl  (4): AG, FR, GE, ZG
## date (1): Time
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

This data needs some cleaning before we can plot it.

This is what it looks like now:

And this is what we want it to look like:

3.1 Step 1: Pivot from wide to long

Think about which columns need to be pivoted and give these to the cols argument of pivot_longer()

3.2 Step 2: Rename variables

Use rename() to change the column names to match the image above.

Now it’s ready for plotting!

4 Recreate desired plot

We want a plot that looks like the one on the website!

This can be done in several steps. See the demo Rmd for more :)

5 Submission: Upload Rmd and HTML

Once you have finished the tasks above, you should knit this Rmd into an HTML and upload both files on the assignment page in a ZIP folder.