Read SPSS file with R

library(readspss) #package to read the original datafile from OFS
library(tidyverse) #package to load the pipeline
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.4     ✓ purrr   0.3.4
## ✓ tibble  3.1.2     ✓ dplyr   1.0.6
## ✓ 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(dplyr)
data <- read.sav("Humiston & Wamsley 2019 data.sav") #read the SPSS data file

cleandata <- data %>%     #remove excluded participants 
  filter(exclude=="no")

Figure 4 data (with data from Jade’s Table 3)

#calculate change
pre_post_change_cued = 0.31 - 0.21

pre_post_change_uncued = 0.25 - 0.3

pre_week_change_cued = 0.40 - 0.21

pre_week_change_uncued = 0.40 - 0.30

#Create dataframe
fig4 <- tibble(
  change_from_pre_to = c("immediate","week"),
  cued = c(0.1, 0.19),
  uncued = c(-0.05, 0.1),#can we change this to use variable names instead like in excel or do we have to manually type it out?
)

print(fig4)
## # A tibble: 2 x 3
##   change_from_pre_to  cued uncued
##   <chr>              <dbl>  <dbl>
## 1 immediate           0.1   -0.05
## 2 week                0.19   0.1

Figure 4 - plot attempt just with cued (uncued not included yet since that would required a grouped bar graph)

#load packages
library(ggplot2)

#create data
cued_uncued_changes <- data.frame(
  time = c("immediate", "week"),
  bias_change = c(0.10,0.19)
)

#convert bias_change to dbl from int
bias_change_dec <- as.double(bias_change)
print(bias_change_dec)

# plot
ggplot(data = fig4, aes(
  x = time,
  y = bias_change_dec
)) +
  geom_col()