Plotting data is fun. We also do it for data exploration (see the section on Exploratory Data Analysis). In these exercises, however, we just want to familiarize ourselves with some of the graphic facilities in R.

So let’s start with a simple task: creating a simple scatter plot. For this purpose, we first load the German General Social Survey - ALLBUS 2021 SUBSET.

library(dplyr)
library(haven)

allbus_2021_dvI <- 
  read_sav(
    "./data/allbus_2021ZA5280_v1-0-0.sav"
  ) %>% 
  sjlabelled::set_na(na = c(-1:-99, 97:98))

Now let’s plot an actual variable from the dataset.

1

Create a scatter plot for the variables pa01 (political_orientation) and fr03b (children suffer under working mothers).
You simply need the plot() command.

2

Add some jitter to the scatter plot.
You need the jitter() function. Have a look at ?jitter for more details on using the function.

3

Add some color of your choice to the plot.
Did you check out the ColourPicker add-in for more modern colors?