Get the SPSS data into RStudio

Load the relevant packages:

library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.4     ✓ purrr   0.3.4
## ✓ tibble  3.1.2     ✓ dplyr   1.0.7
## ✓ tidyr   1.1.3     ✓ stringr 1.4.0
## ✓ readr   1.4.0     ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(janitor)
## 
## Attaching package: 'janitor'
## The following objects are masked from 'package:stats':
## 
##     chisq.test, fisher.test
library(dplyr)

Load the data:

library(remotes)
install_github("JanMarvin/readspss")
## Skipping install of 'readspss' from a github remote, the SHA1 (bbc71e6b) has not changed since last install.
##   Use `force = TRUE` to force installation
library(remotes)
install_github("JanMarvin/readspss")
## Skipping install of 'readspss' from a github remote, the SHA1 (bbc71e6b) has not changed since last install.
##   Use `force = TRUE` to force installation
library(haven)
library(readspss)
replicationdata <- read.sav("Humiston & Wamsley 2019 data.sav")

Exclude participants from the data

cleandata <- replicationdata %>%    #removing participants who were excluded 
  filter(exclude == "no")

Calculate age average

ageaverage <- cleandata %>% #calculating average age including sd using cleaned data
  select(General_1_Age) %>%
  summarise(ageaverage = mean(General_1_Age), 
          agesd = sd(General_1_Age))

print(ageaverage)
##   ageaverage    agesd
## 1   19.54839 1.233929

Calculate average ESS score

ESS = Epworth Sleepiness Scale

ESS <- cleandata %>% 
  select(Epworth_total) %>% 
  summarise(ESSaverage = mean(Epworth_total), 
            ESSsd = sd(Epworth_total))

print(ESS)
##   ESSaverage    ESSsd
## 1   15.29032 2.830707

Calculate SSS

SSS = Stanford Sleepiness Scale

Keeps coming up with error

#SSSerror <- cleandata %>% 
#  select(AlertTest_1_Feel) %>% 
#  summarise(SSSaverage = mean(AlertTest_1_Feel),
#            SSSsd = sd(AlertTest_1_Feel))

Gives non-matching values

SSStrial <- replicationdata %>% 
  select(AlertTest_1_Feel, 
         AlertTest_2_Feel, 
         AlertTest_3_Feel, 
         AlertTest_4_Feel) %>% 
  drop_na() %>% 
  summarise(SSStrialaverage = mean(rbind(AlertTest_1_Feel, AlertTest_2_Feel, AlertTest_3_Feel, AlertTest_4_Feel)),
             SSStrialsd = sd(rbind(AlertTest_1_Feel, AlertTest_2_Feel, AlertTest_3_Feel, AlertTest_4_Feel)))

print(SSStrial)
##   SSStrialaverage SSStrialsd
## 1        2.866667  0.9695649

Another attempt: using mutate to create new variable (SUCCESS~~)

Create new variable SSSvalue

cleandata <- cleandata %>% 
  mutate(
    SSSvalue = as.numeric(
      x = AlertTest_1_Feel,
      levels = 1:5,
      labels = c("1 - Feeling active, vital alert, or wide awake",
      "2 - Functioning at high levels, but not at peak; able to concentrate",
      "3 - Awake, but relaxed; responsive but not fully alert",
      "4 - Somewhat foggy, let down",
      "5 - Foggy; losing interest in remaining awake; slowed down"),
      exclude = NA
    )
  )
SSS <- cleandata %>% 
  select(SSSvalue) %>% 
  summarise(SSSaverage = mean(SSSvalue),
            SSSsd = sd(SSSvalue))

Calculate baseline implicit bias

BIB <- cleandata %>% 
  select(
    base_IAT_race,
    base_IAT_gen) %>% 
  summarise(
    BIBaverage = mean(rbind(base_IAT_race, base_IAT_gen)), 
    BIBsd = sd(rbind(base_IAT_race, base_IAT_gen))
            )

print(BIB)
##   BIBaverage     BIBsd
## 1  0.5565373 0.4058619

Calculate Prenap implicit bias

PrenapIB <- cleandata %>% 
  select(
    pre_IAT_race,
    pre_IAT_gen) %>% 
  summarise(
    PrenapIBaverage = mean(
      rbind(
        pre_IAT_race, 
        pre_IAT_gen)
      ),
    PrenapIBsd = sd(
      rbind(
        pre_IAT_race, 
        pre_IAT_gen))
            )

print(PrenapIB)
##   PrenapIBaverage PrenapIBsd
## 1       0.2566674  0.4776418

Calculate Postnap implicit bias

PostnapIB <- cleandata %>% 
  select(
    post_IAT_race,
    post_IAT_gen) %>% 
  summarise(
    PostnapIBaverage = mean(
      rbind(
        post_IAT_race,
        post_IAT_gen
      )),
    PostnapIBsd = sd(
      rbind(
        post_IAT_race,
        post_IAT_gen
      ))
  )

print(PostnapIB)
##   PostnapIBaverage PostnapIBsd
## 1        0.2776836   0.4585372

Calculate one-week delay implicit bias

OWDIB <- cleandata %>% 
  select(
    week_IAT_race,
    week_IAT_gen) %>% 
  summarise(
    OWDIBaverage = mean(
      rbind(
        week_IAT_race,
        week_IAT_gen
      )
    ),
    OWDIBsd = sd(
      rbind(
        week_IAT_race,
        week_IAT_gen
      )
    )
  )

print(OWDIB)
##   OWDIBaverage   OWDIBsd
## 1    0.3994186 0.4254629

Calculate average sex

Male <- cleandata %>% 
  select(General_1_Sex) %>% 
  tally(General_1_Sex == "Male") 

Male_percentage <- Male/31 #31 as the clean data set has 31 participants

print(Male_percentage)
##          n
## 1 0.483871

Calculate average Cue played during nap (% racial cue)

Napcue <- cleandata %>% 
  select(Cue_condition) %>% 
  tally(Cue_condition == "race cue played")

racialcue_perentage <- Napcue/31

print(racialcue_perentage)
##           n
## 1 0.5483871

Recreate Table 1: Participant characteristics

Install relevant packages

#install.packages("kableExtra")
#install.packages("magick")
#install.packages("gt")

Load relevant packages

library(knitr)
library(kableExtra)
## 
## Attaching package: 'kableExtra'
## The following object is masked from 'package:dplyr':
## 
##     group_rows
library(magick)
## Linking to ImageMagick 6.9.12.3
## Enabled features: cairo, fontconfig, freetype, heic, lcms, pango, raw, rsvg, webp
## Disabled features: fftw, ghostscript, x11
library(gt)
library(glue)
## 
## Attaching package: 'glue'
## The following object is masked from 'package:dplyr':
## 
##     collapse

Create a dataframe for Table 1 (Participant characteristics)

table1 <- tibble(
  Characteristics = c("Age (yrs)", "ESS", "SSS", "Baseline implicit bias", "Prenap implicit bias", "Postnap implicit bias", "One-week delay implicit bias", "Sex (% male)", "Cue played during nap (% racial cue)"),
  Mean = c(19.5, 15.3, 2.81, 0.557, 0.257, 0.278, 0.399, 0.484, 0.548),
  SD = c(1.23, 2.83, 0.749, 0.406, 0.478, 0.459, 0.425, NA, NA)
)

Create and format a table

table1 %>% 
  gt() %>% 
  tab_header(
    title = "Participant characteristics")
Participant characteristics
Characteristics Mean SD
Age (yrs) 19.500 1.230
ESS 15.300 2.830
SSS 2.810 0.749
Baseline implicit bias 0.557 0.406
Prenap implicit bias 0.257 0.478
Postnap implicit bias 0.278 0.459
One-week delay implicit bias 0.399 0.425
Sex (% male) 0.484 NA
Cue played during nap (% racial cue) 0.548 NA