As in the slides, we will, again, use the data from the **German General Social Survey - ALLBUS 2021*. If they are not (still/yet) in your workspace, you first need to load them.

library(haven)

allbus_2021_cda_1 <- read_spss("./data/allbus_2021/ZA5280_v1-0-0.sav")
## Converting atomic to factors. Please wait...

1

Let’s start with a very simple analysis: Compute a t-test to compare the means of the two eastwest groups in the data for the variable pa01. You may get an error message complaining that the variable is not numeric.
For the t-test you can use a base R function named after this test. For converting the variable to numeric you have to use the function as.numeric().

2

Next, use a base R function to run an ANOVA to test the relationship between the left-right self-placement and age groups.
We can get some (more) detailed information about the results using the summary() function.

3

Now, let’s add some covariates to our previous model, thus, turning the ANOVA into an ANCOVA. The covariates we want to include are sex and, again, German region.
Remember that you can simply add covariates in a formula in R with +.

4

Again, as in the case of an ANOVA the output may not be too informative. Compute Tukey Honest Significant Differences to get an idea about what’s going on.
There is the TukeyHSD() function for this purpose.