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 GESIS Panel COVID-19 survey data.

library(dplyr)
library(haven)

gp_covid <- 
  read_sav(
    "./data/ZA5667_v1-1-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 political_orientation and hzcy001a.
You simply need the plot() command.
plot(gp_covid$political_orientation, gp_covid$hzcy001a)

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.
plot(
  jitter(gp_covid$political_orientation, 2), 
  jitter(gp_covid$hzcy001a, 2)
)

3

Add some color of your choice to the plot.
Did you check out the ColourPicker add-in for more modern colors?
plot(
  jitter(gp_covid$political_orientation, 2), 
  jitter(gp_covid$hzcy001a, 2),
  col = c("#1C86EE", "#FFFFFF", "#FFFFFF")
)