History Plotting repeats. Let’s dive into ggplot2
and repeat what we’ve done in base R
using the “grammar of graphics”.
Here’s the Allbus 2021 data again.
library(dplyr)
library(haven)
## Warning: Paket 'haven' wurde unter R Version 4.1.3 erstellt
allbus_2021_dvI <-
read_sav(
"./data/allbus_2021ZA5280_v1-0-0.sav"
) %>%
sjlabelled::set_na(na = c(-1:-99, 97, 98))
pa01
(political_orientation) and fr03b
(children suffer under working mothers).
data + aesthetics + geoms
base R
function jitter does not have to be added; it just replaces the original geom
using geom_jitter()
Boxplots are boring, right? Try to plot the relationship between pa01
(political_orientation) and fr03b
(children suffer under working mothers) as a violin plot! Have a look here for reference: https://ggplot2.tidyverse.org/reference/
geom
? Try geom_violin()
.