ANOVAs

Load Packages

Haven

if (!require(haven)){
  install.packages("haven", dependencies = TRUE)
  require(haven)
}
Loading required package: haven

Tidyverse

if (!require(tidyverse)){
  install.packages("tidyverse", dependencies = TRUE)
  require(tidyverse)
}
Loading required package: tidyverse
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
✔ ggplot2 3.4.0      ✔ purrr   1.0.1 
✔ tibble  3.1.8      ✔ dplyr   1.0.10
✔ tidyr   1.2.1      ✔ stringr 1.5.0 
✔ readr   2.1.3      ✔ forcats 0.5.2 
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()

Afex

if (!require(afex)){
  install.packages("afex", dependencies = TRUE)
  require(afex)
}
Loading required package: afex
Loading required package: lme4
Loading required package: Matrix

Attaching package: 'Matrix'
The following objects are masked from 'package:tidyr':

    expand, pack, unpack
************
Welcome to afex. For support visit: http://afex.singmann.science/
- Functions for ANOVAs: aov_car(), aov_ez(), and aov_4()
- Methods for calculating p-values with mixed(): 'S', 'KR', 'LRT', and 'PB'
- 'afex_aov' and 'mixed' objects can be passed to emmeans() for follow-up tests
- NEWS: emmeans() for ANOVA models now uses model = 'multivariate' as default.
- Get and set global package options with: afex_options()
- Set orthogonal sum-to-zero contrasts globally: set_sum_contrasts()
- For example analyses see: browseVignettes("afex")
************

Attaching package: 'afex'
The following object is masked from 'package:lme4':

    lmer

Import Data

dataset <- read_sav("https://osf.io/p5rqv/download")
dataset %>% #start with dataset
  distinct(Subject, .keep_all = TRUE) -> dataset.unique

Running the ANOVA

(dataset.unique.aov <- aov_ez(id = "Subject", dv = "RaceDFeb", data = dataset.unique, between=c("TrainTyp", "EC")))
Converting to factor: TrainTyp, EC
Contrasts set to contr.sum for the following variables: TrainTyp, EC
Anova Table (Type 3 tests)

Response: RaceDFeb
       Effect     df  MSE         F   ges p.value
1    TrainTyp 1, 670 0.17      0.51 <.001    .477
2          EC 1, 670 0.17 12.40 ***  .018   <.001
3 TrainTyp:EC 1, 670 0.17      0.00 <.001    .961
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1

Calculate Mean and Standard Deviation

(dataset.unique %>% # start with the dataset 
  group_by(EC) %>% # group by the training goal variable
  summarise(mean = mean(RaceDFeb), # get the mean of the DV in each group
            SD = sd(RaceDFeb)) -> trainingGoalDescriptives) # get the SD of the DV in each group
# A tibble: 2 × 3
  EC                            mean    SD
  <dbl+lbl>                    <dbl> <dbl>
1 0 [Self-Pos Black Training]  0.153 0.386
2 1 [Other-Neg Black Training] 0.264 0.435