library(tidyverse)
library(broom)
library(readbulk)
library(lme4)
library(summarytools)

Reading raw data as logged by psychopy and combinging individual participant files using pck ‘readbulk’. We only analysed responses to trials with commutativity statments (“is equal to”).

raw <- read_bulk(directory = "~/data/", extension = ".csv")

data <-
  raw %>%   
  group_by(participant) %>% 
  fill(left) %>% 
  filter(Condition == "is equal to") %>% 
  mutate(resp_true = case_when(left == TRUE & key_resp_2.keys == "left" ~ 1,
                               left == FALSE & key_resp_2.keys == "right" ~ 1,
                               left == TRUE & key_resp_2.keys == "right" ~ 0,
                               left == FALSE & key_resp_2.keys == "left" ~ 0)) %>% 
  mutate(Symmetric = if_else(Symmetric == "Y", 1, 0)) %>% 
  mutate(Symbol = gsub("[^0-9\\.]", "", Symbol) ) %>% 
  ungroup()

T-test of summary statistics (pre-registered)

summary <- data %>% 
  group_by(participant, Symmetric, Symbol) %>% 
  summarize(resp_true = sum(resp_true)/7) #percentage of endorsing commutativity out of the 7 trials per symbol

t_test <- data %>% 
  group_by(participant, Symmetric) %>% 
  summarize(resp_true = sum(resp_true)/70) %>% 
  spread(Symmetric, resp_true) %>% 
  ungroup()

t_test %>% 
  summarise_all(list(mean, sd, min, max))
## # A tibble: 1 x 12
##   participant_fn1 `0_fn1` `1_fn1` participant_fn2 `0_fn2` `1_fn2`
##             <dbl>   <dbl>   <dbl>           <dbl>   <dbl>   <dbl>
## 1            15.5   0.267   0.668            8.80   0.257   0.261
## # … with 6 more variables: participant_fn3 <int>, `0_fn3` <dbl>, `1_fn3` <dbl>,
## #   participant_fn4 <int>, `0_fn4` <dbl>, `1_fn4` <dbl>
tidy(t.test(t_test$`0`, t_test$`1`, paired = TRUE, alternative = 'less'))# t(29) = -5.577, p = .000000255
## # A tibble: 1 x 8
##   estimate statistic   p.value parameter conf.low conf.high method   alternative
##      <dbl>     <dbl>     <dbl>     <dbl>    <dbl>     <dbl> <chr>    <chr>      
## 1   -0.400     -5.58   2.55e-6        29     -Inf    -0.278 Paired … less

Further visual data exploration esp. effect within each participant, effect within each symbol

#Plot of symmetry effect by Symbol
ggplot(summary, aes(as.factor(Symmetric), resp_true, color = Symmetric, group = participant)) +
  geom_line() +
  geom_point() +
  facet_wrap(~Symbol)