6 Van ’t Veer and Sleegers (2019): Anticipatory Stress and Moral Judgments
These chapters aim to bridge between the structured learning in the core chapters, course assessments, and your independent research project. In this particular chapter, we will wrangle a dataset and conduct and interpret an ANOVA.
These chapters are designed so that you can slowly become more independent in your data analysis pipelines and rely less on very structured instructions. Data analysis is all about looking at your raw dataset and identifying what the end product needs to be to apply your visualisation and analysis techniques. You can then create a checklist of tasks to work backwards to get there. There might be a lot of trial and error - don’t worry if this happens to you, it’s a normal part of data analysis!
Assumed level: Analysing multiple predictors/IVs for one outcome/DV, such as semester 2 in Undergraduate Level 2 or Postgraduate RM2.
6.1 Task preparation
6.1.1 Introduction to the data set
For this task, we are using open data from Tilburg University (Veer & Sleegers, 2019). Here is short a description of the experiment:
Immoral behaviors that involve a purity violation have been argued to be uniquely tied to the experience of disgust. It has also been argued that experimentally induced stress may enhance the role of emotion in moral judgment. In a stressful situation, the need to reject and avoid anything that may pose a threat of contamination could be stronger than rejecting other immoral acts, potentially leading to greater condemnation of immoral acts which elicit disgust. The aim of the study was to test whether induced anticipatory stress amplifies the condemnation of disgust-eliciting moral violations. The participants were shown six vignettes describing disgust-eliciting and non-disgust-eliciting moral violations, and they were asked to rate how wrong they felt each vignette was. Participants who were assigned to the induced stress condition were asked to prepare a short public presentation before the experiment, and participants assigned to the control condition were asked to reflect on their latest holiday.
You can read full details of the study here.
To summarise, participants were placed into one of two stress conditions (induced stress/control), and showed both disgust-eliciting and not disgust-eliciting vignettes about moral transgressions. They were asked to rate how wrong they thought each vignette was.
To begin with, answer the following questions:
- What is the experimental design?
- What are the IVs here?
- What are their levels?
- Are they between/within subjects?
- What is the DV?
This is a 2x2 mixed design, with two IVs: stress condition (between-subjects: induced stress/control) and type of moral transgression (within-subjects: disgust-eliciting/other). The DV is participants’ moral wrongness ratings.
You would typically analyse this type of data with an ordinal regression model but here, we will treat the ratings as continuous for the purposes of this exercise (your ANOVA model will automatically calculate mean ratings for each participant). At the end of the chapter, we briefly show you how you might analyse the data with an ordinal model instead.
6.1.2 Organising your files and project for the task
Before we can get started, you need to organise your files and project for the task, so your working directory is in order.
You can create a folder for the data analysis journeys book and a new sub-folder for this chapter, something like:
analysis_journeys, create a new folder for this chapter called something likeVantVeer_analysis. WithinVantVeer_analysis, create two new folders calleddataandfigures.Create an R Project for
VantVeer_analysisas an existing directory for your chapter folder. This should now be your working directory.Create a new R Markdown or Quarto document and give it a sensible title describing the chapter, such as
Van 't Veer and Sleegers (2019). Delete everything below line 10 so you have a blank file to work with and save the file in yourVantVeer_analysisfolder.We are working with one datafile: (VantVeer_2019.csv). Right click the link and select “save link as”, or clicking the links will save the files to your Downloads. Save or copy the file to your
data/folder withinVantVeer_analysis.
You are now ready to start working on the task!
6.2 Overview
6.2.1 Load required packages and read in the data file
Before we explore what wrangling we need to do, load the relevant packages and read the data file.
6.2.2 Explore raw_data
Rows: 199
Columns: 173
$ V8 <chr> "11/3/2014", "11/3/2014", "11/3/2014", "11/3/2014", "11/3/…
$ V9 <chr> "11/3/2014", "11/3/2014", "11/3/2014", "11/3/2014", "11/3/…
$ V10 <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
$ condition <dbl> 2, 1, 1, 1, 2, 1, 2, 2, 1, 1, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2…
$ ppnr <dbl> 2, 1, 3, 4, 7, 6, 5, 9, 16, 13, 18, 14, 12, 17, 11, 10, 8,…
$ Q1.2 <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
$ Q1.3 <dbl> NA, 1, 1, 1, NA, 1, NA, NA, 1, 1, 1, 1, NA, 1, NA, NA, NA,…
$ Q95 <dbl> NA, 1, 1, 1, NA, 1, NA, NA, 1, 1, 1, 1, NA, 1, NA, NA, NA,…
$ Q1.4_1 <dbl> NA, 0.000, 0.000, 0.000, NA, 0.000, NA, NA, 0.000, 0.000, …
$ Q1.4_2 <dbl> NA, 0.000, 0.000, 0.000, NA, 0.000, NA, NA, 0.000, 0.000, …
$ Q1.4_3 <dbl> NA, 181.005, 180.979, 181.013, NA, 180.984, NA, NA, 180.97…
$ Q1.4_4 <dbl> NA, 0, 0, 0, NA, 0, NA, NA, 0, 0, 0, 0, NA, 0, NA, NA, NA,…
$ Q1.5 <dbl> 1, NA, NA, NA, 1, NA, 1, 1, NA, NA, NA, NA, 1, NA, 1, 1, 1…
$ Q1.6_1 <dbl> 5.728, NA, NA, NA, 12.312, NA, 6.386, 7.137, NA, NA, NA, N…
$ Q1.6_2 <dbl> 160.290, NA, NA, NA, 87.378, NA, 6.386, 23.320, NA, NA, NA…
$ Q1.6_3 <dbl> 181.004, NA, NA, NA, 180.998, NA, 181.005, 180.971, NA, NA…
$ Q1.6_4 <dbl> 7, NA, NA, NA, 2, NA, 1, 3, NA, NA, NA, NA, 1, NA, 3, 1, 1…
$ Q2.1 <dbl> NA, 1, 1, 1, NA, 1, NA, NA, 1, 1, 1, 1, NA, 1, NA, NA, NA,…
$ Q2.2 <dbl> 1, NA, NA, NA, 1, NA, 1, 1, NA, NA, NA, NA, 1, NA, 1, 1, 1…
$ Q2.3 <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
$ Q97 <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
$ mood_1 <dbl> 81, 59, 22, 53, 48, 73, NA, 100, 67, 30, 55, 53, 67, 79, 6…
$ stai1_1 <dbl> 3, 2, 1, 3, 4, 3, 3, 4, 3, 1, 3, 4, 3, 4, 4, 3, 2, 2, 4, 3…
$ stai1_2 <dbl> 4, 3, 2, 3, 4, 3, 3, 4, 3, 3, 2, 3, 3, 4, 4, 3, 3, 3, 4, 1…
$ stai1_3 <dbl> 2, 3, 3, 2, 1, 1, 1, 1, 1, 3, 1, 2, 2, 2, 2, 2, 2, 3, 1, 1…
$ stai1_4 <dbl> 2, 1, 3, 2, 1, 1, 1, 1, 1, 3, 1, 2, 1, 1, 1, 2, 2, 3, 2, 2…
$ stai1_5 <dbl> 3, 2, 1, 2, 3, 3, 3, 4, 3, 2, 3, 3, 3, 3, 3, 3, 2, 2, 4, 2…
$ stai1_6 <dbl> 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1…
$ stai1_7 <dbl> 2, 3, 3, 1, 1, 2, 1, 1, 1, 3, 1, 1, 2, 1, 3, 2, 3, 1, 1, 1…
$ stai2_1 <dbl> 3, 2, 1, 2, 2, 3, 3, 3, 3, 1, 2, 2, 3, 1, 2, 1, 3, 2, 2, 3…
$ stai2_2 <dbl> 1, 2, 2, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
$ stai2_3 <dbl> 4, 3, 2, 2, 2, 3, 3, 4, 3, 2, 3, 2, 2, 2, 3, 1, 2, 2, 3, 3…
$ stai2_4 <dbl> 4, 3, 1, 2, 2, 3, 3, 4, 3, 1, 2, 2, 2, 2, 3, 2, 3, 2, 3, 2…
$ stai2_5 <dbl> 1, 2, 4, 1, 1, 2, 1, 1, 1, 3, 1, 2, 1, 2, 1, 1, 1, 2, 1, 1…
$ stai2_6 <dbl> 1, 3, 4, 1, 1, 2, 1, 1, 1, 3, 1, 1, 1, 2, 2, 1, 1, 2, 1, 1…
$ stai2_7 <dbl> 1, 1, 2, 2, 1, 1, 2, 1, 1, 1, 2, 1, 2, 3, 1, 2, 1, 2, 2, 1…
$ stai3_1 <dbl> 3, 2, 1, 2, 4, 3, 3, 4, 3, 1, 3, 3, 2, 3, 2, 2, 2, 2, 3, 2…
$ stai3_2 <dbl> 3, 2, 2, 2, 3, 3, 3, 4, 3, 2, 3, 3, 3, 2, 3, 2, 3, 3, 2, 3…
$ stai3_3 <dbl> 2, 3, 2, 2, 2, 2, 1, 1, 1, 3, 1, 1, 2, 1, 2, 2, 2, 2, 2, 1…
$ stai3_4 <dbl> 1, 2, 3, 1, 1, 1, 2, 1, 2, 3, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1…
$ stai3_5 <dbl> 3, 2, 1, 2, 2, 3, 3, 4, 3, 1, 3, 3, 2, 3, 2, 1, 2, 2, 2, 2…
$ stai3_6 <dbl> 3, 2, 1, 2, 2, 3, 3, 4, 3, 1, 3, 3, 3, 3, 3, 2, 2, 2, 2, 3…
$ gender <dbl> 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2…
$ age <chr> "24", "19", "19", "22", "22", "22", "18", "20", "21", "19"…
$ Q19.7 <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
$ Q118 <dbl> NA, 1, 1, 1, NA, 1, NA, NA, 1, 1, 1, 1, NA, 1, NA, NA, NA,…
$ Q105 <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
$ D1dog <dbl> 9, 9, 8, 8, 3, 9, 9, 9, 6, 6, 8, 7, 9, 9, 6, 7, 8, 9, 8, 5…
$ D2wallet <dbl> 9, 9, 7, 4, 9, 9, 5, 4, 9, 8, 7, 9, 9, 9, 7, 9, 4, 9, 2, 7…
$ D3plane <dbl> 8, 9, 8, 8, 9, 9, 7, 1, 3, 9, 9, 6, 9, 9, 4, 9, 7, 9, 8, 8…
$ D4resume <dbl> 7, 8, 5, 6, 5, 9, 3, 7, 9, 8, 5, 9, 8, 9, 7, 8, 7, 8, 5, 7…
$ D5kitten <dbl> 9, 9, 8, 9, 5, 8, 6, 9, 9, 9, 8, 9, 7, 9, 6, 9, 6, 9, 8, 9…
$ D6trolley <dbl> 5, 3, 5, 2, 4, 5, 3, 1, 1, 9, 2, 4, 5, 5, 3, 4, 2, 1, 3, 6…
$ D7control <dbl> 9, 2, 9, 8, 8, 6, 8, 7, 8, 6, 7, 8, 8, 3, 7, 6, 7, 6, 6, 7…
$ Q120 <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
$ Q113 <dbl> NA, 1, 1, 1, NA, 1, NA, NA, 1, 1, 1, 1, NA, 1, NA, NA, NA,…
$ Q19.11 <dbl> NA, 1, 1, 1, NA, 1, NA, NA, 1, 1, 1, 1, NA, 1, NA, NA, NA,…
$ Q98 <chr> NA, "pres", "pres", "pres", NA, "pres", NA, NA, "pres", "p…
$ Q101 <dbl> NA, 1, 1, 1, NA, 1, NA, NA, 1, 1, 1, 1, NA, 1, NA, NA, NA,…
$ Q114_1 <dbl> NA, 0.00, 0.00, 0.00, NA, 0.00, NA, NA, 0.00, 0.00, 0.00, …
$ Q114_2 <dbl> NA, 0.00, 0.00, 0.00, NA, 0.00, NA, NA, 0.00, 0.00, 0.00, …
$ Q114_3 <dbl> NA, 168.851, 136.044, 125.334, NA, 140.068, NA, NA, 4.441,…
$ Q114_4 <dbl> NA, 0, 0, 0, NA, 0, NA, NA, 0, 0, 0, 0, NA, 0, NA, NA, NA,…
$ presBefore <dbl> NA, 2, 1, 2, NA, 2, NA, NA, 2, 2, 2, 2, NA, 2, NA, NA, NA,…
$ presEva_1 <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
$ presEva_2 <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
$ presEva_3 <dbl> NA, 1, 1, NA, NA, NA, NA, NA, NA, 1, 1, 1, NA, 1, NA, NA, …
$ presEva_4 <dbl> NA, NA, NA, 1, NA, 1, NA, NA, 1, NA, NA, NA, NA, NA, NA, N…
$ presEva_5 <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
$ VervLeuk_1 <dbl> NA, 63, 68, 32, NA, 63, NA, NA, 14, 54, 82, 82, NA, 100, N…
$ VervLeuk_2 <dbl> NA, 58, 26, 59, NA, 54, NA, NA, 78, 42, 7, 18, NA, 0, NA, …
$ challenge_1 <dbl> NA, 58, 65, 80, NA, 50, NA, NA, 47, 64, 72, 68, NA, 0, NA,…
$ moodPost_1 <dbl> NA, 42, 60, 68, NA, 73, NA, NA, 74, 68, 57, 38, NA, 59, NA…
$ stai1post_1 <dbl> NA, 2, 2, 3, NA, 3, NA, NA, 3, 3, 3, 2, NA, 3, NA, NA, NA,…
$ stai1post_2 <dbl> NA, 2, 2, 3, NA, 3, NA, NA, 3, 3, 3, 3, NA, 3, NA, NA, NA,…
$ stai1post_3 <dbl> NA, 3, 2, 1, NA, 1, NA, NA, 1, 1, 2, 2, NA, 1, NA, NA, NA,…
$ stai1post_4 <dbl> NA, 3, 2, 1, NA, 1, NA, NA, 1, 2, 1, 2, NA, 1, NA, NA, NA,…
$ stai1post_5 <dbl> NA, 3, 3, 3, NA, 3, NA, NA, 3, 2, 2, 2, NA, 3, NA, NA, NA,…
$ stai1post_6 <dbl> NA, 2, 1, 1, NA, 1, NA, NA, 1, 1, 3, 2, NA, 1, NA, NA, NA,…
$ stai1post_7 <dbl> NA, 3, 1, 1, NA, 2, NA, NA, 1, 1, 1, 1, NA, 1, NA, NA, NA,…
$ stai2post_1 <dbl> NA, 3, 2, 3, NA, 3, NA, NA, 3, 3, 2, 3, NA, 1, NA, NA, NA,…
$ stai2post_2 <dbl> NA, 2, 1, 1, NA, 1, NA, NA, 1, 1, 1, 1, NA, 1, NA, NA, NA,…
$ stai2post_3 <dbl> NA, 2, 2, 3, NA, 3, NA, NA, 3, 2, 2, 2, NA, 2, NA, NA, NA,…
$ stai2post_4 <dbl> NA, 2, 2, 3, NA, 3, NA, NA, 3, 2, 2, 2, NA, 2, NA, NA, NA,…
$ stai2post_5 <dbl> NA, 3, 1, 1, NA, 1, NA, NA, 1, 1, 1, 1, NA, 2, NA, NA, NA,…
$ stai2post_6 <dbl> NA, 3, 1, 1, NA, 1, NA, NA, 1, 1, 2, 1, NA, 2, NA, NA, NA,…
$ stai2post_7 <dbl> NA, 1, 1, 2, NA, 1, NA, NA, 1, 1, 2, 1, NA, 2, NA, NA, NA,…
$ stai3post_1 <dbl> NA, 3, 2, 3, NA, 3, NA, NA, 3, 2, 2, 2, NA, 2, NA, NA, NA,…
$ stai3post_2 <dbl> NA, 3, 2, 3, NA, 3, NA, NA, 3, 2, 1, 2, NA, 2, NA, NA, NA,…
$ stai3post_3 <dbl> NA, 3, 1, 1, NA, 1, NA, NA, 1, 1, 1, 2, NA, 2, NA, NA, NA,…
$ stai3post_4 <dbl> NA, 2, 1, 1, NA, 1, NA, NA, 1, 1, 2, 1, NA, 1, NA, NA, NA,…
$ stai3post_5 <dbl> NA, 2, 2, 2, NA, 2, NA, NA, 3, 2, 2, 2, NA, 2, NA, NA, NA,…
$ stai3post_6 <dbl> NA, 2, 2, 3, NA, 2, NA, NA, 3, 2, 2, 2, NA, 2, NA, NA, NA,…
$ Q117 <dbl> NA, 1, 1, 1, NA, 1, NA, NA, 1, 1, 1, 1, NA, 1, NA, NA, NA,…
$ pbc_1 <dbl> 3, NA, NA, NA, 3, NA, 3, 1, NA, NA, NA, NA, 4, NA, 2, 5, 2…
$ pbc_2 <dbl> 3, NA, NA, NA, 3, NA, 3, 4, NA, NA, NA, NA, 2, NA, 4, 5, 2…
$ pbc_3 <dbl> 5, NA, NA, NA, 3, NA, 3, 1, NA, NA, NA, NA, 4, NA, 3, 2, 1…
$ pbc_4 <dbl> 5, NA, NA, NA, 3, NA, 5, 4, NA, NA, NA, NA, 3, NA, 3, 5, 4…
$ pbc_5 <dbl> 5, NA, NA, NA, 2, NA, 5, 4, NA, NA, NA, NA, 4, NA, 2, 4, 2…
$ Q117.0 <dbl> 1, NA, NA, NA, 1, NA, 1, 1, NA, NA, NA, NA, 1, NA, 1, 1, 1…
$ rei1 <dbl> 1, NA, NA, NA, 3, NA, 2, 2, NA, NA, NA, NA, 4, NA, 1, 4, 3…
$ rei2 <dbl> 4, NA, NA, NA, 3, NA, 4, 5, NA, NA, NA, NA, 2, NA, 2, 5, 4…
$ rei3 <dbl> 5, NA, NA, NA, 3, NA, 4, 5, NA, NA, NA, NA, 4, NA, 3, 5, 4…
$ rei4 <dbl> 2, NA, NA, NA, 3, NA, 2, 1, NA, NA, NA, NA, 4, NA, 1, 1, 1…
$ rei5 <dbl> 4, NA, NA, NA, 4, NA, 4, 5, NA, NA, NA, NA, 3, NA, 4, 3, 3…
$ rei6 <dbl> 5, NA, NA, NA, 3, NA, 4, 5, NA, NA, NA, NA, 2, NA, 4, 5, 4…
$ rei7 <dbl> 3, NA, NA, NA, 3, NA, 3, 1, NA, NA, NA, NA, 3, NA, 1, 3, 3…
$ rei8 <dbl> 4, NA, NA, NA, 3, NA, 4, 5, NA, NA, NA, NA, 2, NA, 3, 5, 4…
$ rei9 <dbl> 3, NA, NA, NA, 3, NA, 4, 3, NA, NA, NA, NA, 4, NA, 3, 5, 4…
$ rei10 <dbl> 4, NA, NA, NA, 3, NA, 4, 4, NA, NA, NA, NA, 2, NA, 2, 5, 4…
$ rei11 <dbl> 1, NA, NA, NA, 3, NA, 2, 1, NA, NA, NA, NA, 4, NA, 1, 3, 3…
$ rei12 <dbl> 5, NA, NA, NA, NA, NA, 3, 4, NA, NA, NA, NA, 3, NA, 5, 2, …
$ rei13 <dbl> 3, NA, NA, NA, 3, NA, 4, 2, NA, NA, NA, NA, 4, NA, 2, 4, 2…
$ rei14 <dbl> 2, NA, NA, NA, 3, NA, 2, 4, NA, NA, NA, NA, 3, NA, 3, 3, 2…
$ rei15 <dbl> 2, NA, NA, NA, 3, NA, 3, 2, NA, NA, NA, NA, 3, NA, 2, 2, 3…
$ rei16 <dbl> 2, NA, NA, NA, 3, NA, 2, 2, NA, NA, NA, NA, 3, NA, 3, NA, …
$ rei17 <dbl> 3, NA, NA, NA, 3, NA, 3, 4, NA, NA, NA, NA, 4, NA, 5, NA, …
$ rei18 <dbl> 1, NA, NA, NA, 3, NA, 4, 1, NA, NA, NA, NA, 2, NA, 1, NA, …
$ rei19 <dbl> 1, NA, NA, NA, 3, NA, 4, 3, NA, NA, NA, NA, 2, NA, 3, NA, …
$ rei20 <dbl> 3, NA, NA, NA, 3, NA, 1, 1, NA, NA, NA, NA, 3, NA, 4, NA, …
$ rei21 <dbl> 1, NA, NA, NA, 3, NA, 2, 1, NA, NA, NA, NA, 3, NA, 1, 2, 4…
$ rei22 <dbl> 3, NA, NA, NA, 3, NA, 2, 3, NA, NA, NA, NA, 4, NA, 5, 2, 2…
$ rei23 <dbl> 4, NA, NA, NA, 3, NA, 5, 5, NA, NA, NA, NA, 4, NA, 3, 4, 4…
$ rei24 <dbl> 4, NA, NA, NA, 3, NA, 5, 1, NA, NA, NA, NA, 4, NA, 2, 3, 4…
$ rei25 <dbl> 3, NA, NA, NA, 3, NA, 2, 3, NA, NA, NA, NA, 3, NA, 3, 4, 3…
$ rei26 <dbl> 1, NA, NA, NA, 3, NA, 2, 1, NA, NA, NA, NA, 2, NA, 3, 4, 3…
$ rei27 <dbl> 5, NA, NA, NA, 3, NA, 2, 1, NA, NA, NA, NA, 4, NA, 4, 3, 4…
$ rei28 <dbl> 3, NA, NA, NA, 3, NA, 2, 3, NA, NA, NA, NA, 3, NA, 4, 2, 2…
$ rei29 <dbl> 3, NA, NA, NA, 3, NA, 2, 2, NA, NA, NA, NA, 3, NA, 2, 2, 4…
$ rei30 <dbl> 4, NA, NA, NA, 3, NA, 3, 4, NA, NA, NA, NA, 4, NA, 4, 4, 4…
$ rei31 <dbl> 3, NA, NA, NA, 3, NA, 4, 5, NA, NA, NA, NA, 2, NA, 3, 5, 4…
$ rei32 <dbl> 3, NA, NA, NA, 3, NA, 3, 1, NA, NA, NA, NA, 3, NA, 4, 3, 2…
$ rei33 <dbl> 4, NA, NA, NA, 3, NA, 4, 4, NA, NA, NA, NA, 4, NA, 3, 4, 3…
$ rei34 <dbl> 3, NA, NA, NA, 3, NA, 3, 4, NA, NA, NA, NA, 4, NA, 4, 4, 3…
$ rei35 <dbl> 2, NA, NA, NA, 3, NA, 1, 1, NA, NA, NA, NA, 4, NA, 4, 1, 2…
$ rei36 <dbl> 3, NA, NA, NA, 3, NA, 4, 4, NA, NA, NA, NA, 3, NA, 2, 4, 3…
$ rei37 <dbl> 2, NA, NA, NA, 3, NA, 2, 3, NA, NA, NA, NA, 4, NA, 1, 2, 2…
$ rei38 <dbl> 4, NA, NA, NA, 3, NA, 4, 4, NA, NA, NA, NA, 3, NA, 4, 3, 2…
$ rei39 <dbl> 2, NA, NA, NA, 3, NA, 2, 3, NA, NA, NA, NA, 4, NA, 4, 2, 3…
$ rei40 <dbl> 2, NA, NA, NA, 3, NA, 3, 1, NA, NA, NA, NA, 3, NA, 1, 2, 2…
$ Maia1_1 <dbl> 3, NA, NA, NA, 4, NA, 5, 4, NA, NA, NA, NA, 2, NA, 2, 6, 3…
$ Maia1_2 <dbl> 5, NA, NA, NA, 4, NA, 5, 5, NA, NA, NA, NA, 5, NA, 4, 6, 5…
$ Maia1_3 <dbl> 5, NA, NA, NA, 4, NA, 5, 5, NA, NA, NA, NA, 5, NA, 4, 6, 2…
$ Maia1_4 <dbl> 5, NA, NA, NA, 4, NA, 6, 5, NA, NA, NA, NA, 4, NA, 4, 5, 3…
$ Maia1_5 <dbl> 5, NA, NA, NA, 4, NA, 5, 2, NA, NA, NA, NA, 4, NA, 5, 4, 4…
$ Maia1_6 <dbl> 5, NA, NA, NA, 4, NA, 5, 5, NA, NA, NA, NA, 5, NA, 5, 5, 3…
$ Maia1_7 <dbl> 5, NA, NA, NA, 4, NA, 3, 4, NA, NA, NA, NA, 5, NA, 5, 5, 4…
$ Maia1_8 <dbl> 4, NA, NA, NA, 4, NA, 4, 2, NA, NA, NA, NA, 2, NA, 2, 3, 4…
$ Maia1_9 <dbl> 3, NA, NA, NA, 4, NA, 2, 1, NA, NA, NA, NA, 4, NA, 2, 4, 5…
$ Maia1_10 <dbl> 5, NA, NA, NA, 4, NA, 5, 3, NA, NA, NA, NA, 3, NA, 5, 1, 3…
$ Maia1_11 <dbl> 5, NA, NA, NA, 4, NA, 2, 4, NA, NA, NA, NA, 5, NA, 6, 2, 2…
$ Maia1_12 <dbl> 4, NA, NA, NA, 4, NA, 3, 4, NA, NA, NA, NA, 3, NA, 4, 2, 3…
$ Maia1_13 <dbl> 5, NA, NA, NA, 4, NA, 4, 6, NA, NA, NA, NA, 4, NA, 6, 4, 5…
$ Maia1_14 <dbl> 5, NA, NA, NA, 4, NA, 3, 6, NA, NA, NA, NA, 3, NA, 5, 5, 3…
$ Maia1_15 <dbl> 5, NA, NA, NA, 4, NA, 4, 5, NA, NA, NA, NA, 5, NA, 5, 4, 4…
$ Maia1_16 <dbl> 5, NA, NA, NA, 4, NA, 3, 6, NA, NA, NA, NA, 4, NA, 5, 4, 2…
$ Maia2_1 <dbl> 5, NA, NA, NA, 4, NA, 4, 6, NA, NA, NA, NA, 4, NA, 5, 3, 4…
$ Maia2_2 <dbl> 5, NA, NA, NA, 4, NA, 5, 6, NA, NA, NA, NA, 3, NA, 5, 6, 4…
$ Maia2_3 <dbl> 5, NA, NA, NA, 4, NA, 4, 3, NA, NA, NA, NA, 5, NA, 4, 6, 4…
$ Maia2_4 <dbl> 5, NA, NA, NA, 4, NA, 5, 5, NA, NA, NA, NA, 4, NA, 5, 2, 3…
$ Maia2_5 <dbl> 5, NA, NA, NA, 4, NA, 5, 5, NA, NA, NA, NA, 4, NA, 5, 3, 3…
$ Maia2_6 <dbl> 5, NA, NA, NA, 4, NA, 6, 5, NA, NA, NA, NA, 4, NA, 6, 5, 4…
$ Maia2_7 <dbl> 5, NA, NA, NA, 4, NA, 4, 3, NA, NA, NA, NA, 3, NA, 2, 3, 2…
$ Maia2_8 <dbl> 5, NA, NA, NA, 4, NA, 4, 4, NA, NA, NA, NA, 3, NA, 3, 3, 2…
$ Maia2_9 <dbl> 5, NA, NA, NA, 4, NA, 5, 5, NA, NA, NA, NA, 3, NA, 2, 4, 4…
$ Maia2_10 <dbl> 5, NA, NA, NA, 4, NA, 3, 5, NA, NA, NA, NA, 4, NA, 2, 3, 3…
$ Maia2_11 <dbl> 5, NA, NA, NA, 4, NA, 4, 4, NA, NA, NA, NA, 5, NA, 5, 4, 2…
$ Maia2_12 <dbl> 4, NA, NA, NA, 4, NA, 3, 1, NA, NA, NA, NA, 3, NA, 4, 4, 2…
$ Maia2_13 <dbl> 4, NA, NA, NA, 4, NA, 4, 4, NA, NA, NA, NA, 3, NA, 4, 4, 3…
$ Maia2_14 <dbl> 5, NA, NA, NA, 4, NA, 4, 5, NA, NA, NA, NA, 3, NA, 6, 4, 5…
$ Maia2_15 <dbl> 5, NA, NA, NA, 4, NA, 5, 5, NA, NA, NA, NA, 4, NA, 6, 5, 3…
$ Maia2_16 <dbl> 5, NA, NA, NA, 4, NA, 5, 5, NA, NA, NA, NA, 4, NA, 6, 5, 4…
$ Q19.12 <dbl> 1, NA, NA, NA, 1, NA, 1, 1, NA, NA, NA, NA, 1, NA, 1, 1, 1…
The dataset has a lot of columns - if you want to learn more or explore the dataset further with some multiple regression models with the control variables, you can read the full description on the data website. For the purposes of today’s exercise, the columns that matter to us are:
| Variable | Type | Description |
|---|---|---|
| ppnr | double | Participant number. |
| condition | double | Experimental condition: 1 for control, 2 for induced stress |
| gender | double | Participant gender, 1 for male, 2 for female |
| age | character | Participant age |
| D1dog | double | How wrong is this moral transgression from 1-9, 1= perfectly ok, 9= very wrong |
| D2wallet | double | How wrong is this moral transgression from 1-9, 1= perfectly ok, 9= very wrong |
| D3plane | double | How wrong is this moral transgression from 1-9, 1= perfectly ok, 9= very wrong |
| D4resume | double | How wrong is this moral transgression from 1-9, 1= perfectly ok, 9= very wrong |
| D5kitten | double | How wrong is this moral transgression from 1-9, 1= perfectly ok, 9= very wrong |
| D6trolley | double | How wrong is this moral transgression from 1-9, 1= perfectly ok, 9= very wrong |
In terms of the vignettes, D2wallet, D4resume, and D6trolley are “other” type of moral transgressions, whereas D1dog, D3plane and D5kitten are disgust-eliciting moral transgressions. If you wish to read the vignettes, they are linked on the data website. Bear in mind some of them are designed to elicit disgust so they can be quite unpleasant.
D7control is a control vignette which we will ignore for the purposes of this exercise - if you want to explore further, you can keep it in through the data wrangling steps and conduct an analysis of whether the moral wrongness ratings for this variable differ depending on the stress condition.
Now we have introduced the data set, spend some time exploring it. For example, open the data objects as a tab to scroll around, explore with glimpse(), and try quickly plotting some of the variables with ggplot2.
Do you notice any variables that look the wrong type? Can you see any responses in there that are going to cause problems (hint: look at responses in the age column in particular)?
6.3 Wrangling the data for demographics
Rows: 199
Columns: 173
$ V8 <chr> "11/3/2014", "11/3/2014", "11/3/2014", "11/3/2014", "11/3/…
$ V9 <chr> "11/3/2014", "11/3/2014", "11/3/2014", "11/3/2014", "11/3/…
$ V10 <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
$ condition <dbl> 2, 1, 1, 1, 2, 1, 2, 2, 1, 1, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2…
$ ppnr <dbl> 2, 1, 3, 4, 7, 6, 5, 9, 16, 13, 18, 14, 12, 17, 11, 10, 8,…
$ Q1.2 <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
$ Q1.3 <dbl> NA, 1, 1, 1, NA, 1, NA, NA, 1, 1, 1, 1, NA, 1, NA, NA, NA,…
$ Q95 <dbl> NA, 1, 1, 1, NA, 1, NA, NA, 1, 1, 1, 1, NA, 1, NA, NA, NA,…
$ Q1.4_1 <dbl> NA, 0.000, 0.000, 0.000, NA, 0.000, NA, NA, 0.000, 0.000, …
$ Q1.4_2 <dbl> NA, 0.000, 0.000, 0.000, NA, 0.000, NA, NA, 0.000, 0.000, …
$ Q1.4_3 <dbl> NA, 181.005, 180.979, 181.013, NA, 180.984, NA, NA, 180.97…
$ Q1.4_4 <dbl> NA, 0, 0, 0, NA, 0, NA, NA, 0, 0, 0, 0, NA, 0, NA, NA, NA,…
$ Q1.5 <dbl> 1, NA, NA, NA, 1, NA, 1, 1, NA, NA, NA, NA, 1, NA, 1, 1, 1…
$ Q1.6_1 <dbl> 5.728, NA, NA, NA, 12.312, NA, 6.386, 7.137, NA, NA, NA, N…
$ Q1.6_2 <dbl> 160.290, NA, NA, NA, 87.378, NA, 6.386, 23.320, NA, NA, NA…
$ Q1.6_3 <dbl> 181.004, NA, NA, NA, 180.998, NA, 181.005, 180.971, NA, NA…
$ Q1.6_4 <dbl> 7, NA, NA, NA, 2, NA, 1, 3, NA, NA, NA, NA, 1, NA, 3, 1, 1…
$ Q2.1 <dbl> NA, 1, 1, 1, NA, 1, NA, NA, 1, 1, 1, 1, NA, 1, NA, NA, NA,…
$ Q2.2 <dbl> 1, NA, NA, NA, 1, NA, 1, 1, NA, NA, NA, NA, 1, NA, 1, 1, 1…
$ Q2.3 <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
$ Q97 <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
$ mood_1 <dbl> 81, 59, 22, 53, 48, 73, NA, 100, 67, 30, 55, 53, 67, 79, 6…
$ stai1_1 <dbl> 3, 2, 1, 3, 4, 3, 3, 4, 3, 1, 3, 4, 3, 4, 4, 3, 2, 2, 4, 3…
$ stai1_2 <dbl> 4, 3, 2, 3, 4, 3, 3, 4, 3, 3, 2, 3, 3, 4, 4, 3, 3, 3, 4, 1…
$ stai1_3 <dbl> 2, 3, 3, 2, 1, 1, 1, 1, 1, 3, 1, 2, 2, 2, 2, 2, 2, 3, 1, 1…
$ stai1_4 <dbl> 2, 1, 3, 2, 1, 1, 1, 1, 1, 3, 1, 2, 1, 1, 1, 2, 2, 3, 2, 2…
$ stai1_5 <dbl> 3, 2, 1, 2, 3, 3, 3, 4, 3, 2, 3, 3, 3, 3, 3, 3, 2, 2, 4, 2…
$ stai1_6 <dbl> 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1…
$ stai1_7 <dbl> 2, 3, 3, 1, 1, 2, 1, 1, 1, 3, 1, 1, 2, 1, 3, 2, 3, 1, 1, 1…
$ stai2_1 <dbl> 3, 2, 1, 2, 2, 3, 3, 3, 3, 1, 2, 2, 3, 1, 2, 1, 3, 2, 2, 3…
$ stai2_2 <dbl> 1, 2, 2, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
$ stai2_3 <dbl> 4, 3, 2, 2, 2, 3, 3, 4, 3, 2, 3, 2, 2, 2, 3, 1, 2, 2, 3, 3…
$ stai2_4 <dbl> 4, 3, 1, 2, 2, 3, 3, 4, 3, 1, 2, 2, 2, 2, 3, 2, 3, 2, 3, 2…
$ stai2_5 <dbl> 1, 2, 4, 1, 1, 2, 1, 1, 1, 3, 1, 2, 1, 2, 1, 1, 1, 2, 1, 1…
$ stai2_6 <dbl> 1, 3, 4, 1, 1, 2, 1, 1, 1, 3, 1, 1, 1, 2, 2, 1, 1, 2, 1, 1…
$ stai2_7 <dbl> 1, 1, 2, 2, 1, 1, 2, 1, 1, 1, 2, 1, 2, 3, 1, 2, 1, 2, 2, 1…
$ stai3_1 <dbl> 3, 2, 1, 2, 4, 3, 3, 4, 3, 1, 3, 3, 2, 3, 2, 2, 2, 2, 3, 2…
$ stai3_2 <dbl> 3, 2, 2, 2, 3, 3, 3, 4, 3, 2, 3, 3, 3, 2, 3, 2, 3, 3, 2, 3…
$ stai3_3 <dbl> 2, 3, 2, 2, 2, 2, 1, 1, 1, 3, 1, 1, 2, 1, 2, 2, 2, 2, 2, 1…
$ stai3_4 <dbl> 1, 2, 3, 1, 1, 1, 2, 1, 2, 3, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1…
$ stai3_5 <dbl> 3, 2, 1, 2, 2, 3, 3, 4, 3, 1, 3, 3, 2, 3, 2, 1, 2, 2, 2, 2…
$ stai3_6 <dbl> 3, 2, 1, 2, 2, 3, 3, 4, 3, 1, 3, 3, 3, 3, 3, 2, 2, 2, 2, 3…
$ gender <dbl> 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2…
$ age <chr> "24", "19", "19", "22", "22", "22", "18", "20", "21", "19"…
$ Q19.7 <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
$ Q118 <dbl> NA, 1, 1, 1, NA, 1, NA, NA, 1, 1, 1, 1, NA, 1, NA, NA, NA,…
$ Q105 <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
$ D1dog <dbl> 9, 9, 8, 8, 3, 9, 9, 9, 6, 6, 8, 7, 9, 9, 6, 7, 8, 9, 8, 5…
$ D2wallet <dbl> 9, 9, 7, 4, 9, 9, 5, 4, 9, 8, 7, 9, 9, 9, 7, 9, 4, 9, 2, 7…
$ D3plane <dbl> 8, 9, 8, 8, 9, 9, 7, 1, 3, 9, 9, 6, 9, 9, 4, 9, 7, 9, 8, 8…
$ D4resume <dbl> 7, 8, 5, 6, 5, 9, 3, 7, 9, 8, 5, 9, 8, 9, 7, 8, 7, 8, 5, 7…
$ D5kitten <dbl> 9, 9, 8, 9, 5, 8, 6, 9, 9, 9, 8, 9, 7, 9, 6, 9, 6, 9, 8, 9…
$ D6trolley <dbl> 5, 3, 5, 2, 4, 5, 3, 1, 1, 9, 2, 4, 5, 5, 3, 4, 2, 1, 3, 6…
$ D7control <dbl> 9, 2, 9, 8, 8, 6, 8, 7, 8, 6, 7, 8, 8, 3, 7, 6, 7, 6, 6, 7…
$ Q120 <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
$ Q113 <dbl> NA, 1, 1, 1, NA, 1, NA, NA, 1, 1, 1, 1, NA, 1, NA, NA, NA,…
$ Q19.11 <dbl> NA, 1, 1, 1, NA, 1, NA, NA, 1, 1, 1, 1, NA, 1, NA, NA, NA,…
$ Q98 <chr> NA, "pres", "pres", "pres", NA, "pres", NA, NA, "pres", "p…
$ Q101 <dbl> NA, 1, 1, 1, NA, 1, NA, NA, 1, 1, 1, 1, NA, 1, NA, NA, NA,…
$ Q114_1 <dbl> NA, 0.00, 0.00, 0.00, NA, 0.00, NA, NA, 0.00, 0.00, 0.00, …
$ Q114_2 <dbl> NA, 0.00, 0.00, 0.00, NA, 0.00, NA, NA, 0.00, 0.00, 0.00, …
$ Q114_3 <dbl> NA, 168.851, 136.044, 125.334, NA, 140.068, NA, NA, 4.441,…
$ Q114_4 <dbl> NA, 0, 0, 0, NA, 0, NA, NA, 0, 0, 0, 0, NA, 0, NA, NA, NA,…
$ presBefore <dbl> NA, 2, 1, 2, NA, 2, NA, NA, 2, 2, 2, 2, NA, 2, NA, NA, NA,…
$ presEva_1 <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
$ presEva_2 <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
$ presEva_3 <dbl> NA, 1, 1, NA, NA, NA, NA, NA, NA, 1, 1, 1, NA, 1, NA, NA, …
$ presEva_4 <dbl> NA, NA, NA, 1, NA, 1, NA, NA, 1, NA, NA, NA, NA, NA, NA, N…
$ presEva_5 <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
$ VervLeuk_1 <dbl> NA, 63, 68, 32, NA, 63, NA, NA, 14, 54, 82, 82, NA, 100, N…
$ VervLeuk_2 <dbl> NA, 58, 26, 59, NA, 54, NA, NA, 78, 42, 7, 18, NA, 0, NA, …
$ challenge_1 <dbl> NA, 58, 65, 80, NA, 50, NA, NA, 47, 64, 72, 68, NA, 0, NA,…
$ moodPost_1 <dbl> NA, 42, 60, 68, NA, 73, NA, NA, 74, 68, 57, 38, NA, 59, NA…
$ stai1post_1 <dbl> NA, 2, 2, 3, NA, 3, NA, NA, 3, 3, 3, 2, NA, 3, NA, NA, NA,…
$ stai1post_2 <dbl> NA, 2, 2, 3, NA, 3, NA, NA, 3, 3, 3, 3, NA, 3, NA, NA, NA,…
$ stai1post_3 <dbl> NA, 3, 2, 1, NA, 1, NA, NA, 1, 1, 2, 2, NA, 1, NA, NA, NA,…
$ stai1post_4 <dbl> NA, 3, 2, 1, NA, 1, NA, NA, 1, 2, 1, 2, NA, 1, NA, NA, NA,…
$ stai1post_5 <dbl> NA, 3, 3, 3, NA, 3, NA, NA, 3, 2, 2, 2, NA, 3, NA, NA, NA,…
$ stai1post_6 <dbl> NA, 2, 1, 1, NA, 1, NA, NA, 1, 1, 3, 2, NA, 1, NA, NA, NA,…
$ stai1post_7 <dbl> NA, 3, 1, 1, NA, 2, NA, NA, 1, 1, 1, 1, NA, 1, NA, NA, NA,…
$ stai2post_1 <dbl> NA, 3, 2, 3, NA, 3, NA, NA, 3, 3, 2, 3, NA, 1, NA, NA, NA,…
$ stai2post_2 <dbl> NA, 2, 1, 1, NA, 1, NA, NA, 1, 1, 1, 1, NA, 1, NA, NA, NA,…
$ stai2post_3 <dbl> NA, 2, 2, 3, NA, 3, NA, NA, 3, 2, 2, 2, NA, 2, NA, NA, NA,…
$ stai2post_4 <dbl> NA, 2, 2, 3, NA, 3, NA, NA, 3, 2, 2, 2, NA, 2, NA, NA, NA,…
$ stai2post_5 <dbl> NA, 3, 1, 1, NA, 1, NA, NA, 1, 1, 1, 1, NA, 2, NA, NA, NA,…
$ stai2post_6 <dbl> NA, 3, 1, 1, NA, 1, NA, NA, 1, 1, 2, 1, NA, 2, NA, NA, NA,…
$ stai2post_7 <dbl> NA, 1, 1, 2, NA, 1, NA, NA, 1, 1, 2, 1, NA, 2, NA, NA, NA,…
$ stai3post_1 <dbl> NA, 3, 2, 3, NA, 3, NA, NA, 3, 2, 2, 2, NA, 2, NA, NA, NA,…
$ stai3post_2 <dbl> NA, 3, 2, 3, NA, 3, NA, NA, 3, 2, 1, 2, NA, 2, NA, NA, NA,…
$ stai3post_3 <dbl> NA, 3, 1, 1, NA, 1, NA, NA, 1, 1, 1, 2, NA, 2, NA, NA, NA,…
$ stai3post_4 <dbl> NA, 2, 1, 1, NA, 1, NA, NA, 1, 1, 2, 1, NA, 1, NA, NA, NA,…
$ stai3post_5 <dbl> NA, 2, 2, 2, NA, 2, NA, NA, 3, 2, 2, 2, NA, 2, NA, NA, NA,…
$ stai3post_6 <dbl> NA, 2, 2, 3, NA, 2, NA, NA, 3, 2, 2, 2, NA, 2, NA, NA, NA,…
$ Q117 <dbl> NA, 1, 1, 1, NA, 1, NA, NA, 1, 1, 1, 1, NA, 1, NA, NA, NA,…
$ pbc_1 <dbl> 3, NA, NA, NA, 3, NA, 3, 1, NA, NA, NA, NA, 4, NA, 2, 5, 2…
$ pbc_2 <dbl> 3, NA, NA, NA, 3, NA, 3, 4, NA, NA, NA, NA, 2, NA, 4, 5, 2…
$ pbc_3 <dbl> 5, NA, NA, NA, 3, NA, 3, 1, NA, NA, NA, NA, 4, NA, 3, 2, 1…
$ pbc_4 <dbl> 5, NA, NA, NA, 3, NA, 5, 4, NA, NA, NA, NA, 3, NA, 3, 5, 4…
$ pbc_5 <dbl> 5, NA, NA, NA, 2, NA, 5, 4, NA, NA, NA, NA, 4, NA, 2, 4, 2…
$ Q117.0 <dbl> 1, NA, NA, NA, 1, NA, 1, 1, NA, NA, NA, NA, 1, NA, 1, 1, 1…
$ rei1 <dbl> 1, NA, NA, NA, 3, NA, 2, 2, NA, NA, NA, NA, 4, NA, 1, 4, 3…
$ rei2 <dbl> 4, NA, NA, NA, 3, NA, 4, 5, NA, NA, NA, NA, 2, NA, 2, 5, 4…
$ rei3 <dbl> 5, NA, NA, NA, 3, NA, 4, 5, NA, NA, NA, NA, 4, NA, 3, 5, 4…
$ rei4 <dbl> 2, NA, NA, NA, 3, NA, 2, 1, NA, NA, NA, NA, 4, NA, 1, 1, 1…
$ rei5 <dbl> 4, NA, NA, NA, 4, NA, 4, 5, NA, NA, NA, NA, 3, NA, 4, 3, 3…
$ rei6 <dbl> 5, NA, NA, NA, 3, NA, 4, 5, NA, NA, NA, NA, 2, NA, 4, 5, 4…
$ rei7 <dbl> 3, NA, NA, NA, 3, NA, 3, 1, NA, NA, NA, NA, 3, NA, 1, 3, 3…
$ rei8 <dbl> 4, NA, NA, NA, 3, NA, 4, 5, NA, NA, NA, NA, 2, NA, 3, 5, 4…
$ rei9 <dbl> 3, NA, NA, NA, 3, NA, 4, 3, NA, NA, NA, NA, 4, NA, 3, 5, 4…
$ rei10 <dbl> 4, NA, NA, NA, 3, NA, 4, 4, NA, NA, NA, NA, 2, NA, 2, 5, 4…
$ rei11 <dbl> 1, NA, NA, NA, 3, NA, 2, 1, NA, NA, NA, NA, 4, NA, 1, 3, 3…
$ rei12 <dbl> 5, NA, NA, NA, NA, NA, 3, 4, NA, NA, NA, NA, 3, NA, 5, 2, …
$ rei13 <dbl> 3, NA, NA, NA, 3, NA, 4, 2, NA, NA, NA, NA, 4, NA, 2, 4, 2…
$ rei14 <dbl> 2, NA, NA, NA, 3, NA, 2, 4, NA, NA, NA, NA, 3, NA, 3, 3, 2…
$ rei15 <dbl> 2, NA, NA, NA, 3, NA, 3, 2, NA, NA, NA, NA, 3, NA, 2, 2, 3…
$ rei16 <dbl> 2, NA, NA, NA, 3, NA, 2, 2, NA, NA, NA, NA, 3, NA, 3, NA, …
$ rei17 <dbl> 3, NA, NA, NA, 3, NA, 3, 4, NA, NA, NA, NA, 4, NA, 5, NA, …
$ rei18 <dbl> 1, NA, NA, NA, 3, NA, 4, 1, NA, NA, NA, NA, 2, NA, 1, NA, …
$ rei19 <dbl> 1, NA, NA, NA, 3, NA, 4, 3, NA, NA, NA, NA, 2, NA, 3, NA, …
$ rei20 <dbl> 3, NA, NA, NA, 3, NA, 1, 1, NA, NA, NA, NA, 3, NA, 4, NA, …
$ rei21 <dbl> 1, NA, NA, NA, 3, NA, 2, 1, NA, NA, NA, NA, 3, NA, 1, 2, 4…
$ rei22 <dbl> 3, NA, NA, NA, 3, NA, 2, 3, NA, NA, NA, NA, 4, NA, 5, 2, 2…
$ rei23 <dbl> 4, NA, NA, NA, 3, NA, 5, 5, NA, NA, NA, NA, 4, NA, 3, 4, 4…
$ rei24 <dbl> 4, NA, NA, NA, 3, NA, 5, 1, NA, NA, NA, NA, 4, NA, 2, 3, 4…
$ rei25 <dbl> 3, NA, NA, NA, 3, NA, 2, 3, NA, NA, NA, NA, 3, NA, 3, 4, 3…
$ rei26 <dbl> 1, NA, NA, NA, 3, NA, 2, 1, NA, NA, NA, NA, 2, NA, 3, 4, 3…
$ rei27 <dbl> 5, NA, NA, NA, 3, NA, 2, 1, NA, NA, NA, NA, 4, NA, 4, 3, 4…
$ rei28 <dbl> 3, NA, NA, NA, 3, NA, 2, 3, NA, NA, NA, NA, 3, NA, 4, 2, 2…
$ rei29 <dbl> 3, NA, NA, NA, 3, NA, 2, 2, NA, NA, NA, NA, 3, NA, 2, 2, 4…
$ rei30 <dbl> 4, NA, NA, NA, 3, NA, 3, 4, NA, NA, NA, NA, 4, NA, 4, 4, 4…
$ rei31 <dbl> 3, NA, NA, NA, 3, NA, 4, 5, NA, NA, NA, NA, 2, NA, 3, 5, 4…
$ rei32 <dbl> 3, NA, NA, NA, 3, NA, 3, 1, NA, NA, NA, NA, 3, NA, 4, 3, 2…
$ rei33 <dbl> 4, NA, NA, NA, 3, NA, 4, 4, NA, NA, NA, NA, 4, NA, 3, 4, 3…
$ rei34 <dbl> 3, NA, NA, NA, 3, NA, 3, 4, NA, NA, NA, NA, 4, NA, 4, 4, 3…
$ rei35 <dbl> 2, NA, NA, NA, 3, NA, 1, 1, NA, NA, NA, NA, 4, NA, 4, 1, 2…
$ rei36 <dbl> 3, NA, NA, NA, 3, NA, 4, 4, NA, NA, NA, NA, 3, NA, 2, 4, 3…
$ rei37 <dbl> 2, NA, NA, NA, 3, NA, 2, 3, NA, NA, NA, NA, 4, NA, 1, 2, 2…
$ rei38 <dbl> 4, NA, NA, NA, 3, NA, 4, 4, NA, NA, NA, NA, 3, NA, 4, 3, 2…
$ rei39 <dbl> 2, NA, NA, NA, 3, NA, 2, 3, NA, NA, NA, NA, 4, NA, 4, 2, 3…
$ rei40 <dbl> 2, NA, NA, NA, 3, NA, 3, 1, NA, NA, NA, NA, 3, NA, 1, 2, 2…
$ Maia1_1 <dbl> 3, NA, NA, NA, 4, NA, 5, 4, NA, NA, NA, NA, 2, NA, 2, 6, 3…
$ Maia1_2 <dbl> 5, NA, NA, NA, 4, NA, 5, 5, NA, NA, NA, NA, 5, NA, 4, 6, 5…
$ Maia1_3 <dbl> 5, NA, NA, NA, 4, NA, 5, 5, NA, NA, NA, NA, 5, NA, 4, 6, 2…
$ Maia1_4 <dbl> 5, NA, NA, NA, 4, NA, 6, 5, NA, NA, NA, NA, 4, NA, 4, 5, 3…
$ Maia1_5 <dbl> 5, NA, NA, NA, 4, NA, 5, 2, NA, NA, NA, NA, 4, NA, 5, 4, 4…
$ Maia1_6 <dbl> 5, NA, NA, NA, 4, NA, 5, 5, NA, NA, NA, NA, 5, NA, 5, 5, 3…
$ Maia1_7 <dbl> 5, NA, NA, NA, 4, NA, 3, 4, NA, NA, NA, NA, 5, NA, 5, 5, 4…
$ Maia1_8 <dbl> 4, NA, NA, NA, 4, NA, 4, 2, NA, NA, NA, NA, 2, NA, 2, 3, 4…
$ Maia1_9 <dbl> 3, NA, NA, NA, 4, NA, 2, 1, NA, NA, NA, NA, 4, NA, 2, 4, 5…
$ Maia1_10 <dbl> 5, NA, NA, NA, 4, NA, 5, 3, NA, NA, NA, NA, 3, NA, 5, 1, 3…
$ Maia1_11 <dbl> 5, NA, NA, NA, 4, NA, 2, 4, NA, NA, NA, NA, 5, NA, 6, 2, 2…
$ Maia1_12 <dbl> 4, NA, NA, NA, 4, NA, 3, 4, NA, NA, NA, NA, 3, NA, 4, 2, 3…
$ Maia1_13 <dbl> 5, NA, NA, NA, 4, NA, 4, 6, NA, NA, NA, NA, 4, NA, 6, 4, 5…
$ Maia1_14 <dbl> 5, NA, NA, NA, 4, NA, 3, 6, NA, NA, NA, NA, 3, NA, 5, 5, 3…
$ Maia1_15 <dbl> 5, NA, NA, NA, 4, NA, 4, 5, NA, NA, NA, NA, 5, NA, 5, 4, 4…
$ Maia1_16 <dbl> 5, NA, NA, NA, 4, NA, 3, 6, NA, NA, NA, NA, 4, NA, 5, 4, 2…
$ Maia2_1 <dbl> 5, NA, NA, NA, 4, NA, 4, 6, NA, NA, NA, NA, 4, NA, 5, 3, 4…
$ Maia2_2 <dbl> 5, NA, NA, NA, 4, NA, 5, 6, NA, NA, NA, NA, 3, NA, 5, 6, 4…
$ Maia2_3 <dbl> 5, NA, NA, NA, 4, NA, 4, 3, NA, NA, NA, NA, 5, NA, 4, 6, 4…
$ Maia2_4 <dbl> 5, NA, NA, NA, 4, NA, 5, 5, NA, NA, NA, NA, 4, NA, 5, 2, 3…
$ Maia2_5 <dbl> 5, NA, NA, NA, 4, NA, 5, 5, NA, NA, NA, NA, 4, NA, 5, 3, 3…
$ Maia2_6 <dbl> 5, NA, NA, NA, 4, NA, 6, 5, NA, NA, NA, NA, 4, NA, 6, 5, 4…
$ Maia2_7 <dbl> 5, NA, NA, NA, 4, NA, 4, 3, NA, NA, NA, NA, 3, NA, 2, 3, 2…
$ Maia2_8 <dbl> 5, NA, NA, NA, 4, NA, 4, 4, NA, NA, NA, NA, 3, NA, 3, 3, 2…
$ Maia2_9 <dbl> 5, NA, NA, NA, 4, NA, 5, 5, NA, NA, NA, NA, 3, NA, 2, 4, 4…
$ Maia2_10 <dbl> 5, NA, NA, NA, 4, NA, 3, 5, NA, NA, NA, NA, 4, NA, 2, 3, 3…
$ Maia2_11 <dbl> 5, NA, NA, NA, 4, NA, 4, 4, NA, NA, NA, NA, 5, NA, 5, 4, 2…
$ Maia2_12 <dbl> 4, NA, NA, NA, 4, NA, 3, 1, NA, NA, NA, NA, 3, NA, 4, 4, 2…
$ Maia2_13 <dbl> 4, NA, NA, NA, 4, NA, 4, 4, NA, NA, NA, NA, 3, NA, 4, 4, 3…
$ Maia2_14 <dbl> 5, NA, NA, NA, 4, NA, 4, 5, NA, NA, NA, NA, 3, NA, 6, 4, 5…
$ Maia2_15 <dbl> 5, NA, NA, NA, 4, NA, 5, 5, NA, NA, NA, NA, 4, NA, 6, 5, 3…
$ Maia2_16 <dbl> 5, NA, NA, NA, 4, NA, 5, 5, NA, NA, NA, NA, 4, NA, 6, 5, 4…
$ Q19.12 <dbl> 1, NA, NA, NA, 1, NA, 1, 1, NA, NA, NA, NA, 1, NA, 1, 1, 1…
Rows: 188
Columns: 10
$ ppnr <dbl> 2, 1, 3, 4, 7, 6, 5, 9, 16, 13, 18, 14, 12, 17, 11, 10, 8, 1…
$ condition <dbl> 2, 1, 1, 1, 2, 1, 2, 2, 1, 1, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, …
$ gender <dbl> 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, …
$ age <dbl> 24, 19, 19, 22, 22, 22, 18, 20, 21, 19, 19, 18, 18, 18, 18, …
$ D1dog <dbl> 9, 9, 8, 8, 3, 9, 9, 9, 6, 6, 8, 7, 9, 9, 6, 7, 8, 9, 8, 5, …
$ D2wallet <dbl> 9, 9, 7, 4, 9, 9, 5, 4, 9, 8, 7, 9, 9, 9, 7, 9, 4, 9, 2, 7, …
$ D3plane <dbl> 8, 9, 8, 8, 9, 9, 7, 1, 3, 9, 9, 6, 9, 9, 4, 9, 7, 9, 8, 8, …
$ D4resume <dbl> 7, 8, 5, 6, 5, 9, 3, 7, 9, 8, 5, 9, 8, 9, 7, 8, 7, 8, 5, 7, …
$ D5kitten <dbl> 9, 9, 8, 9, 5, 8, 6, 9, 9, 9, 8, 9, 7, 9, 6, 9, 6, 9, 8, 9, …
$ D6trolley <dbl> 5, 3, 5, 2, 4, 5, 3, 1, 1, 9, 2, 4, 5, 5, 3, 4, 2, 1, 3, 6, …
Before we give you a task list, try and switch between the raw data and the wrangled data. Make a list of all the differences you can see between the two data objects.
What type is each variable? Has it changed from the raw data?
What number of observations do we have? What type of responses have been taken out and why?
When you get as far as you can, check the task list which explains all the steps we applied, but not how to do them. Then, you can check the solution for our code.
6.3.1 Task list
These are all the steps we applied to create the wrangled data object:
Select the appropriate columns required
Remove NAs. Here we removed all rows with NAs, but this can sometimes be tricky, if you have NAs in your demographics but not experimental data and you are short on data - it’s not always easy to decide which rows to keep. This is a discussion you should have with your dissertation supervisor, and usually it’s good to decide in advance what your strategy is (pre-registration).
Remove any responses which said
testfor age.Convert
ageto a numeric variable.
6.3.2 Solution
This is the code we used to tidy up the dataset before calculating demographic information. As long as you get the same end result, the exact code is not important. In coding, there are multiple ways of getting to the same end result - if your code is not the exact same as ours, that’s not a problem.
6.4 Calculating demographics
Next, add a new code chunk to calculate the following demographics on using clean_data.
6.4.1 Demographics
- How many men and women were there? There were women and men.
- To 2 decimal places, the mean age of all the participants was (SD = ).
6.5 Wrangling the data for analysis
Rows: 188
Columns: 10
$ ppnr <dbl> 2, 1, 3, 4, 7, 6, 5, 9, 16, 13, 18, 14, 12, 17, 11, 10, 8, 1…
$ condition <dbl> 2, 1, 1, 1, 2, 1, 2, 2, 1, 1, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, …
$ gender <dbl> 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, …
$ age <dbl> 24, 19, 19, 22, 22, 22, 18, 20, 21, 19, 19, 18, 18, 18, 18, …
$ D1dog <dbl> 9, 9, 8, 8, 3, 9, 9, 9, 6, 6, 8, 7, 9, 9, 6, 7, 8, 9, 8, 5, …
$ D2wallet <dbl> 9, 9, 7, 4, 9, 9, 5, 4, 9, 8, 7, 9, 9, 9, 7, 9, 4, 9, 2, 7, …
$ D3plane <dbl> 8, 9, 8, 8, 9, 9, 7, 1, 3, 9, 9, 6, 9, 9, 4, 9, 7, 9, 8, 8, …
$ D4resume <dbl> 7, 8, 5, 6, 5, 9, 3, 7, 9, 8, 5, 9, 8, 9, 7, 8, 7, 8, 5, 7, …
$ D5kitten <dbl> 9, 9, 8, 9, 5, 8, 6, 9, 9, 9, 8, 9, 7, 9, 6, 9, 6, 9, 8, 9, …
$ D6trolley <dbl> 5, 3, 5, 2, 4, 5, 3, 1, 1, 9, 2, 4, 5, 5, 3, 4, 2, 1, 3, 6, …
Rows: 1,128
Columns: 7
$ ppnr <dbl> 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, …
$ condition <chr> "induced_stress", "induced_stress", "induced_stress…
$ gender <dbl> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, …
$ age <dbl> 24, 24, 24, 24, 24, 24, 19, 19, 19, 19, 19, 19, 19,…
$ vignette <chr> "D1dog", "D2wallet", "D3plane", "D4resume", "D5kitt…
$ rating <dbl> 9, 9, 8, 7, 9, 5, 9, 9, 9, 8, 9, 3, 8, 7, 8, 5, 8, …
$ transgression_type <chr> "disgust", "other", "disgust", "other", "disgust", …
Before we give you a task list, try and switch between the half wrangled and fully wrangled data. Make a list of all the differences you can see between the two data objects.
Are the data in long or wide format? Which variables have been pivoted?
Which variables do each of the datasets have? How would you create these variables in the fully wrangled data based on the variables you have in the half wrangled data?
Which columns contain our information about the two IVs? Which column contains our DV?
What is the variable type of each variable?
Has the content of any of the columns changed? If so, why do you think this was done?
When you get as far as you can, check the task list which explains all the steps we applied, but not how to do them. Then, you can check the solution for our code.
6.5.1 Task list
These are all the steps we applied to create the fully wrangled data object:
Pivot the vignette columns so you have one column for the vignette, and one for the participant rating
Add a new column for the transgression type (our second IV). In this column, vignettes 1,3, and 5 should be marked as disgust-eliciting, and vignettes 2, 4, and 6 should be marked as other.
Change condition from numeric to character
Give the levels of condition variable more self-explanatory labels (control/induced stress instead of 1 and 2)
6.5.2 Solution
This is the code we used to pivot the data and add a new column to show the transgression type for each vignette, and to relabel the levels of our condition IV.
analysis_data <- clean_data %>%
pivot_longer(D1dog:D6trolley,
names_to = "vignette",
values_to = "rating") %>%
mutate(transgression_type = case_match(vignette,
"D1dog" ~ "disgust",
"D2wallet" ~ "other",
"D3plane"~ "disgust",
"D4resume"~ "other",
"D5kitten"~ "disgust",
"D6trolley"~"other")) %>%
mutate(condition = as.character(condition)) %>%
mutate(condition = case_match(condition,
"1"~"control",
"2"~"induced_stress"
))6.6 Descriptive statistics and visualisation
Now it’s time to actually look at the analysis. To remind you, we have two IVs: stress condition as a between-subjects (participants either were placed into the control condition, or stress was induced by telling them they have to do a public speaking presentation), and type of moral transgression as within-subjects (disgust-eliciting vignettes, and other type of more transgressions)
The hypotheses we are testing are as follows:
There will be a main effect of stress condition: participants in induced stress condition will have higher moral wrongness ratings than participants in control condition.
There will be a main effect of transgression type such that disgust-eliciting vignettes will have higher moral wrongness ratings than other type of moral transgressions.
There will be an interaction such that the effect of transgression type will be stronger in the induced stress condition as opposed to the control condition.
Sketch on paper a simple graph of how it would look like if all three hypotheses were supported (when working with factorial data, this is a very helpful thing to do to understand how your hypotheses map onto your specific variables)
Next, add a new code chunk and for our descriptive statistics, calculate the cell means and SDs for our design (means and SDs for each of the four IV combinations), and make a visualisation with ggplot that shows the distribution of scores for both IVs at the same time. What do you think the findings will be based on your descriptives and visualisation?
If you are struggling to figure out which visualisation to make, try to recreate this one before looking at the solution code:

To two decimal places, the highest mean rating was in . The mean was (SD = ). The lowest mean rating was in . The mean was (SD = ).
6.6.1 Solution
This is the code we used to compute cell means and a suggested plot
descriptives <- analysis_data %>%
group_by(condition, transgression_type) %>%
summarise(mean_rating = round(mean(rating), 2),
sd_rating = round(sd(rating), 2))
ggplot(analysis_data,
aes(x = condition, y = rating, fill = transgression_type)) +
geom_boxplot() +
theme_bw() +
scale_fill_viridis_d(option="inferno", begin=0.3, end=0.8)6.7 Inferential statistics: ANOVA
Finally, we’ll run an ANOVA to test our hypotheses.
First, run the code to conduct a factorial ANOVA on our data and test your assumptions.
Remember that you need to run post-hoc tests if the interaction effect is significant to examine whether your hypothesis is supported. To create good hypotheses for interaction effects, it’s important to specify exactly how you expect the interaction to look like - just saying you expect a significant interaction is ambiguous and leaves space for accidental misconduct.
Our first hypothesis of the main effect of stress condition was . Participants in the had higher moral wrongness ratings.
Our second hypotheses of the main effect of moral transgression type was . Vignettes in the condition had higher moral wrongness ratings.
Our hypothesis of the interaction between moral transgression type and stress condition was .
Here, our interaction effect was not significant so we don’t need to conduct post-hoc tests. If the effect had been significant, we would have used emmeans to conduct pairwise comparisons
6.7.1 Solution
This is the code we used to compute the ANOVA and test the assumptions
Anova Table (Type 3 tests)
Response: rating
Effect df MSE F pes p.value
1 condition 1, 186 2.12 7.05 ** .037 .009
2 transgression_type 1, 186 1.39 162.09 *** .466 <.001
3 condition:transgression_type 1, 186 1.39 0.27 .001 .602
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
It looks like there are some issues with normality - I will suggest some glm-based approaches below. If doing a dissertation, always discuss your modelling strategy with your supervisor!
For homogeneity of variance, we need to check this for out between-subjects factor. Some code for this is provided below, but you can find more here
# Isolate standardised residuals as a data frame
residuals <- as.data.frame(rstandard(mod_1$lm)) %>%
select(residuals_disgust = disgust,
residuals_other = other)
# add residuals to the wide version of the data, so we have the groups
data_wide <- analysis_data %>%
pivot_wider(id_cols = c(ppnr, condition),
names_from = vignette,
values_from = rating) %>%
bind_cols(residuals)
# Pivot longer and calculate the square root of absolute standardised residuals
residuals_long <- data_wide %>%
pivot_longer(cols = residuals_disgust:residuals_other,
names_to = "transg_type",
values_to = "Residuals") %>%
mutate(std_residuals = sqrt(abs(Residuals)))
# Plot the residuals
residuals_long %>%
# we need groups as numbers for the line to plot
mutate(condition = case_match(condition,
"induced_stress" ~ 1,
"control" ~ 2)) %>%
ggplot(aes(x = condition, y = std_residuals)) +
geom_point() +
# add line joining the mean of residuals per group
stat_summary(geom = "line",
fun = mean,
color = "blue",
linewidth = 1.5) +
labs(x = "Condition", y = "Standardised Residuals")For the sake of the argument, here is how the model and output would look like if you chose to conduct the analysis as a multiple regression or an ordinal model instead of using the ANOVA function - when working with real-life datasets that might not meet the assumptions (which is quite common), glms can sometimes provide a more flexible option.
Please bear in mind that if you choose to approach the data with several model iterations, you must choose the model based on its fit to the data (as evidenced by R squared and/or AIC), not based on statistical significance of the predictors. It’s best practice to detail your model selection strategy in advance (pre-registration).
#First deviation coding the variables for ease of interpretation
analysis_data <- mutate(analysis_data,
cond_dev=ifelse(condition=="induced_stress", -0.5, 0.5),
vig_dev=ifelse(transgression_type=="disgust", -0.5, 0.5))
#This is how the model would look like as standard multiple regression
mod_2 <- lm(rating~cond_dev * vig_dev,
data = analysis_data)
summary(mod_2)
check_model(mod_2)
#Here is how an ordinal model would look like with the package ordinal - this way we don't treat the ordinal DV as continuous. Please note that the interpretation and output look slightly different, you can find some guidance here if you are interested: https://psyteachr.github.io/statsres-v2/01-05-glm.html#ordinal-regression
library(ordinal)
#For ordinal models, your DV needs to be a factor
analysis_data <- analysis_data %>%
mutate(rating_ordinal = as.factor(rating))
#The model itself does not differ (note the function clm instead of lm)
mod_3 <- clm(rating_ordinal ~ cond_dev * vig_dev,
data = analysis_data)
summary(mod_3)6.8 Conclusion
Well done! Hopefully you found this exercise useful - when working with a new dataset, always try to picture how the data need to look like for your analysis, and then work out a task list for the steps you need to take to get there.
