1 Packages

2 Read in data

# read data 
tdata_between <- read.delim("tdata_between.txt", header=TRUE, sep="\t", na.strings="NA", dec=".", strip.white=TRUE) # Exp1a

tdata_within <- read.delim("tdata_within.txt", header=TRUE, sep="\t", na.strings="NA", dec=".", strip.white=TRUE) # Exp1b

tdata_manip <- read.delim("tdata_manip.txt", header=TRUE, sep="\t", na.strings="NA", dec=".", strip.white=TRUE) # Exp2

tdata_2d <- read.delim("tdata_between_2d.txt", header=TRUE, sep="\t", na.strings="NA", dec=".", strip.white=TRUE) # Exp3

3 Plot Results

3.1 Plot Results of Exp. 1a

tdata <- tdata_between

# declare factors and their levels 
tdata$Dimensions <- factor(tdata$Dimensions, levels = c("3D", "2D"), labels = c("3D", "2D"))

tdata$Transformation <- factor(tdata$Transformation, levels = c("Small", "Angle", "90_rot", "180_rot", "X_sym", "Y_transl", "X_transl"), 
                               labels = c("Size", "Shape", "90-Rot.", "180-Rot.", "X-Sym.", "Y-Tran.","X-Tran."))

tdata$Side <- factor(tdata$Side, levels = c("left", "right"), labels = c("left", "right"))


# recode responses so that 1 = first, 2 = second, 3 = both
tdata$selection_rec <- c(1:length(tdata$sID))
tdata$selection_rec[tdata$Side =="left" & tdata$Value == 1] <- "symm"
tdata$selection_rec[tdata$Side =="left" & tdata$Value == 2] <- "non-symm"
tdata$selection_rec[tdata$Side =="right" & tdata$Value == 1] <- "non-symm"
tdata$selection_rec[tdata$Side =="right" & tdata$Value == 2] <- "symm"



#tdata_strength <-  tdata_strength %>% gather(Entity, Strength, g1:g3, factor_key=TRUE)

 
tdata$selection_rec <- factor(tdata$selection_rec, levels = c("symm", "non-symm"), labels = c("Y-Symm.", "Not-Y-Symm."))
# create a summary dataset that also contains the percentages
plotdata_between <- tdata %>%
  group_by(Dimensions, Transformation, selection_rec) %>%
  summarize(n = n()) %>% 
  mutate(pct = n/sum(n),
         lbl = scales::percent(pct))
## `summarise()` has grouped output by 'Dimensions', 'Transformation'. You can override using the `.groups` argument.
## Warning: Ignoring unknown aesthetics: y

3.2 Plot Results of Exp. 1b

tdata <- tdata_within

# declare factors and their levels 
tdata$Dimensions <- factor(tdata$Dimensions, levels = c("3D", "2D"), labels = c("3D", "2D"))

tdata$Transformation <- factor(tdata$Transformation, levels = c("Small", "Angle", "90_rot", "180_rot", "X_sym", "Y_transl", "X_transl"), 
                               labels = c("Size", "Shape", "90-Rot.", "180-Rot.", "X-Sym.", "Y-Tran.","X-Tran."))

tdata$Side <- factor(tdata$Side, levels = c("left", "right"), labels = c("left", "right"))


# recode responses so that 1 = first, 2 = second, 3 = both
tdata$selection_rec <- c(1:length(tdata$sID))
tdata$selection_rec[tdata$Side =="left" & tdata$Value == 1] <- "symm"
tdata$selection_rec[tdata$Side =="left" & tdata$Value == 2] <- "non-symm"
tdata$selection_rec[tdata$Side =="right" & tdata$Value == 1] <- "non-symm"
tdata$selection_rec[tdata$Side =="right" & tdata$Value == 2] <- "symm"



#tdata_strength <-  tdata_strength %>% gather(Entity, Strength, g1:g3, factor_key=TRUE)

 
tdata$selection_rec <- factor(tdata$selection_rec, levels = c("symm", "non-symm"), labels = c("Y-Symm.", "Not-Y-Symm."))
# create a summary dataset that also contains the percentages
plotdata_within <- tdata %>%
  group_by(Dimensions, Transformation, selection_rec) %>%
  summarize(n = n()) %>% 
  mutate(pct = n/sum(n),
         lbl = scales::percent(pct))
## `summarise()` has grouped output by 'Dimensions', 'Transformation'. You can override using the `.groups` argument.
## Warning: Ignoring unknown aesthetics: y

3.3 Plot Results of Exp. 2

tdata <- tdata_manip

# declare factors and their levels 
#$Dimensions <- factor(tdata$Dimensions, levels = c("3D", "2D"), labels = c("3D", "2D"))

tdata$Transformation <- factor(tdata$Transformation, levels = c("Small", "Angle", "90_rot", "180_rot", "X_sym", "Y_transl", "X_transl"), 
                               labels = c("Size", "Shape", "90-Rot.", "180-Rot.", "X-Sym.", "Y-Tran.","X-Tran."))

tdata$Side <- factor(tdata$Side, levels = c("left", "right"), labels = c("left", "right"))


# recode responses so that 1 = first, 2 = second, 3 = both
tdata$selection_rec <- c(1:length(tdata$sID))
tdata$selection_rec[tdata$Side =="left" & tdata$Value == 1] <- "symm"
tdata$selection_rec[tdata$Side =="left" & tdata$Value == 2] <- "non-symm"
tdata$selection_rec[tdata$Side =="right" & tdata$Value == 1] <- "non-symm"
tdata$selection_rec[tdata$Side =="right" & tdata$Value == 2] <- "symm"



#tdata_strength <-  tdata_strength %>% gather(Entity, Strength, g1:g3, factor_key=TRUE)


tdata$selection_rec <- factor(tdata$selection_rec, levels = c("symm", "non-symm"), labels = c("Y-Symm.", "Not-Y-Symm."))
# create a summary dataset that also contains the percentages
plotdata_2d <- tdata %>%
  group_by(Transformation, selection_rec) %>%
  summarize(n = n()) %>% 
  mutate(pct = n/sum(n),
         lbl = scales::percent(pct))
## `summarise()` has grouped output by 'Transformation'. You can override using the `.groups` argument.
## Warning: Ignoring unknown aesthetics: y

3.4 Plot Results of Exp. 3

tdata <- tdata_2d

# declare factors and their levels 
tdata$Dimensions <- factor(tdata$Dimensions, levels = c("3D", "2D"), labels = c("3D", "2D"))

tdata$Transformation <- factor(tdata$Transformation, levels = c("Small", "Angle", "90_rot", "180_rot", "X_sym", "Y_transl", "X_transl"), 
                               labels = c("Size", "Shape", "90-Rot.", "180-Rot.", "X-Sym.", "Y-Tran.","X-Tran."))

tdata$Side <- factor(tdata$Side, levels = c("left", "right"), labels = c("left", "right"))


# recode responses so that 1 = first, 2 = second, 3 = both
tdata$selection_rec <- c(1:length(tdata$sID))
tdata$selection_rec[tdata$Side =="left" & tdata$Value == 1] <- "symm"
tdata$selection_rec[tdata$Side =="left" & tdata$Value == 2] <- "non-symm"
tdata$selection_rec[tdata$Side =="right" & tdata$Value == 1] <- "non-symm"
tdata$selection_rec[tdata$Side =="right" & tdata$Value == 2] <- "symm"



#tdata_strength <-  tdata_strength %>% gather(Entity, Strength, g1:g3, factor_key=TRUE)


tdata$selection_rec <- factor(tdata$selection_rec, levels = c("symm", "non-symm"), labels = c("Y-Symm.", "Not-Y-Symm."))
# create a summary dataset that also contains the percentages
plotdata_2d <- tdata %>%
  group_by(Dimensions, Transformation, selection_rec) %>%
  summarize(n = n()) %>% 
  mutate(pct = n/sum(n),
         lbl = scales::percent(pct))
## `summarise()` has grouped output by 'Dimensions', 'Transformation'. You can override using the `.groups` argument.
## Warning: Ignoring unknown aesthetics: y

4 Main effect of Dimensions

4.1 Exp 1a

tdata <- tdata_between

# declare factors and their levels 
tdata$Dimensions <- factor(tdata$Dimensions, levels = c("3D", "2D"), labels = c("3D", "2D"))

tdata$Transformation <- factor(tdata$Transformation, levels = c("Small", "Angle", "90_rot", "180_rot", "X_sym", "Y_transl", "X_transl"), 
                               labels = c("Size", "Shape", "90-Rot.", "180-Rot.", "X-Sym.", "Y-Tran.","X-Tran."))

tdata$Side <- factor(tdata$Side, levels = c("left", "right"), labels = c("left", "right"))


# recode responses so that 1 = first, 2 = second, 3 = both
tdata$selection_rec <- c(1:length(tdata$sID))
tdata$selection_rec[tdata$Side =="left" & tdata$Value == 1] <- "symm"
tdata$selection_rec[tdata$Side =="left" & tdata$Value == 2] <- "non-symm"
tdata$selection_rec[tdata$Side =="right" & tdata$Value == 1] <- "non-symm"
tdata$selection_rec[tdata$Side =="right" & tdata$Value == 2] <- "symm"



#tdata_strength <-  tdata_strength %>% gather(Entity, Strength, g1:g3, factor_key=TRUE)

 
tdata$selection_rec <- factor(tdata$selection_rec, levels = c("symm", "non-symm"), labels = c("Y-Symm.", "Not-Y-Symm."))
# create a summary dataset that also contains the percentages
plotdata_between <- tdata %>%
  group_by(Dimensions, selection_rec) %>%
  summarize(n = n()) %>% 
  mutate(pct = n/sum(n),
         lbl = scales::percent(pct))
## `summarise()` has grouped output by 'Dimensions'. You can override using the `.groups` argument.
## Warning: Ignoring unknown aesthetics: y
## Warning: Unknown or uninitialised column: `Transformation`.
library(scales)
theme_set(theme_light(base_size = 12, base_family = "Poppins"))

g<- ggplot(plotdata, 
       aes(x = "3D (between)",
           y = pct,
           fill = selection_rec)) +
  geom_bar(stat = "identity",
           position = "fill") +
  scale_y_continuous(breaks = seq(0, 1, .25), 
                     label = percent) +
  geom_text(aes(label = lbl), 
            size = 4, 
            position = position_stack(vjust = 0.5)) +
  scale_fill_brewer(palette = "Pastel1") +
  labs(y = "Percentage", 
       fill = "Selec. Obj.",
       x = "Test condition",
       title = "3D Context a (N = 854)")+
  annotate(geom = "hline",yintercept = 0.5, y = 0.5, color = "black", size = 1, linetype='dotted')+
  annotate("pointrange", x = 1, y = 1 - plotdata_sub$pct, 
           ymin = 1 - plotdata_sub$pct - plotdata_sub$CI, 
           ymax = 1- plotdata_sub$pct + plotdata_sub$CI, 
           colour = "black", size = 0.8, shape = 22, fill = "lightblue", fatten = 1)+
  theme(legend.position = "top", axis.title = element_text(size = 15), axis.text = element_text(size = 13, color = "black"),
        legend.text = element_text(size = 13))
## Warning: Ignoring unknown aesthetics: y
g

#ggsave("selections_between_main.pdf",width=3.5,height=5)
#ggsave("selections_between_main.svg",width=3.5,height=5)

4.2 Exp. 1b

tdata <- tdata_within

# declare factors and their levels 
tdata$Dimensions <- factor(tdata$Dimensions, levels = c("3D", "2D"), labels = c("3D", "2D"))

tdata$Transformation <- factor(tdata$Transformation, levels = c("Small", "Angle", "90_rot", "180_rot", "X_sym", "Y_transl", "X_transl"), 
                               labels = c("Size", "Shape", "90-Rot.", "180-Rot.", "X-Sym.", "Y-Tran.","X-Tran."))

tdata$Side <- factor(tdata$Side, levels = c("left", "right"), labels = c("left", "right"))


# recode responses so that 1 = first, 2 = second, 3 = both
tdata$selection_rec <- c(1:length(tdata$sID))
tdata$selection_rec[tdata$Side =="left" & tdata$Value == 1] <- "symm"
tdata$selection_rec[tdata$Side =="left" & tdata$Value == 2] <- "non-symm"
tdata$selection_rec[tdata$Side =="right" & tdata$Value == 1] <- "non-symm"
tdata$selection_rec[tdata$Side =="right" & tdata$Value == 2] <- "symm"



#tdata_strength <-  tdata_strength %>% gather(Entity, Strength, g1:g3, factor_key=TRUE)

 
tdata$selection_rec <- factor(tdata$selection_rec, levels = c("symm", "non-symm"), labels = c("Y-Symm.", "Not-Y-Symm."))
# create a summary dataset that also contains the percentages
plotdata_within <- tdata %>%
  group_by(Dimensions, selection_rec) %>%
  summarize(n = n()) %>% 
  mutate(pct = n/sum(n),
         lbl = scales::percent(pct))
## `summarise()` has grouped output by 'Dimensions'. You can override using the `.groups` argument.
## Warning: Ignoring unknown aesthetics: y
## Warning: Unknown or uninitialised column: `Transformation`.
library(scales)
theme_set(theme_light(base_size = 12, base_family = "Poppins"))

g<- ggplot(plotdata, 
       aes(x = "3D (within)",
           y = pct,
           fill = selection_rec)) +
  geom_bar(stat = "identity",
           position = "fill") +
  scale_y_continuous(breaks = seq(0, 1, .25), 
                     label = percent) +
  geom_text(aes(label = lbl), 
            size = 4, 
            position = position_stack(vjust = 0.5)) +
  scale_fill_brewer(palette = "Pastel1") +
  labs(y = "Percentage", 
       fill = "Selec. Obj.",
       x = "Test condition",
       title = "3D Context b (N = 854)")+
  annotate(geom = "hline",yintercept = 0.5, y = 0.5, color = "black", size = 1, linetype='dotted')+
  annotate("pointrange", x = 1, y = 1 - plotdata_sub$pct, 
           ymin = 1 - plotdata_sub$pct - plotdata_sub$CI, 
           ymax = 1- plotdata_sub$pct + plotdata_sub$CI, 
           colour = "black", size = 0.8, shape = 22, fill = "lightblue", fatten = 1)+
  theme(legend.position = "top", axis.title = element_text(size = 15), axis.text = element_text(size = 13, color = "black"),
        legend.text = element_text(size = 13))
## Warning: Ignoring unknown aesthetics: y
g

#ggsave("selections_within_main.pdf",width=3.5,height=5)
#ggsave("selections_within_main.svg",width=3.5,height=5)

4.3 Exp. 2

tdata <- tdata_manip

# declare factors and their levels 
#tdata$Dimensions <- factor(tdata$Dimensions, levels = c("3D", "2D"), labels = c("3D", "2D"))

tdata$Transformation <- factor(tdata$Transformation, levels = c("Small", "Angle", "90_rot", "180_rot", "X_sym", "Y_transl", "X_transl"), 
                               labels = c("Size", "Shape", "90-Rot.", "180-Rot.", "X-Sym.", "Y-Tran.","X-Tran."))

tdata$Side <- factor(tdata$Side, levels = c("left", "right"), labels = c("left", "right"))


# recode responses so that 1 = first, 2 = second, 3 = both
tdata$selection_rec <- c(1:length(tdata$sID))
tdata$selection_rec[tdata$Side =="left" & tdata$Value == 1] <- "symm"
tdata$selection_rec[tdata$Side =="left" & tdata$Value == 2] <- "non-symm"
tdata$selection_rec[tdata$Side =="right" & tdata$Value == 1] <- "non-symm"
tdata$selection_rec[tdata$Side =="right" & tdata$Value == 2] <- "symm"



#tdata_strength <-  tdata_strength %>% gather(Entity, Strength, g1:g3, factor_key=TRUE)

 
tdata$selection_rec <- factor(tdata$selection_rec, levels = c("symm", "non-symm"), labels = c("Y-Symm.", "Not-Y-Symm."))
# create a summary dataset that also contains the percentages
plotdata_within <- tdata %>%
  group_by(selection_rec) %>%
  summarize(n = n()) %>% 
  mutate(pct = n/sum(n),
         lbl = scales::percent(pct))
## Warning: Ignoring unknown aesthetics: y
## Warning: Unknown or uninitialised column: `Transformation`.
library(scales)
theme_set(theme_light(base_size = 12, base_family = "Poppins"))

g<- ggplot(plotdata, 
       aes(x = "3D with manipul. obj.",
           y = pct,
           fill = selection_rec)) +
  geom_bar(stat = "identity",
           position = "fill") +
  scale_y_continuous(breaks = seq(0, 1, .25), 
                     label = percent) +
  geom_text(aes(label = lbl), 
            size = 4, 
            position = position_stack(vjust = 0.5)) +
  scale_fill_brewer(palette = "Pastel1") +
  labs(y = "Percentage", 
       fill = "Selec. Obj.",
       x = "Test condition",
       title = "3D Context c (N = 868)")+
  annotate(geom = "hline",yintercept = 0.5, y = 0.5, color = "black", size = 1, linetype='dotted')+
  annotate("pointrange", x = 1, y = 1 - plotdata_sub$pct, 
           ymin = 1 - plotdata_sub$pct - plotdata_sub$CI, 
           ymax = 1- plotdata_sub$pct + plotdata_sub$CI, 
           colour = "black", size = 0.8, shape = 22, fill = "lightblue", fatten = 1)+
  theme(legend.position = "top", axis.title = element_text(size = 15), axis.text = element_text(size = 13, color = "black"),
        legend.text = element_text(size = 13))
## Warning: Ignoring unknown aesthetics: y
g

ggsave("selections_within_main.pdf",width=3.5,height=5)
#ggsave("selections_within_main.svg",width=3.5,height=5)

4.4 Exp. 3

tdata <- tdata_2d

# declare factors and their levels 
tdata$Dimensions <- factor(tdata$Dimensions, levels = c("3D", "2D"), labels = c("3D", "2D"))

tdata$Transformation <- factor(tdata$Transformation, levels = c("Small", "Angle", "90_rot", "180_rot", "X_sym", "Y_transl", "X_transl"), 
                               labels = c("Size", "Shape", "90-Rot.", "180-Rot.", "X-Sym.", "Y-Tran.","X-Tran."))

tdata$Side <- factor(tdata$Side, levels = c("left", "right"), labels = c("left", "right"))


# recode responses so that 1 = first, 2 = second, 3 = both
tdata$selection_rec <- c(1:length(tdata$sID))
tdata$selection_rec[tdata$Side =="left" & tdata$Value == 1] <- "symm"
tdata$selection_rec[tdata$Side =="left" & tdata$Value == 2] <- "non-symm"
tdata$selection_rec[tdata$Side =="right" & tdata$Value == 1] <- "non-symm"
tdata$selection_rec[tdata$Side =="right" & tdata$Value == 2] <- "symm"



#tdata_strength <-  tdata_strength %>% gather(Entity, Strength, g1:g3, factor_key=TRUE)

 
tdata$selection_rec <- factor(tdata$selection_rec, levels = c("symm", "non-symm"), labels = c("Y-Symm.", "Not-Y-Symm."))
# create a summary dataset that also contains the percentages
plotdata_2d <- tdata %>%
  group_by(Dimensions, selection_rec) %>%
  summarize(n = n()) %>% 
  mutate(pct = n/sum(n),
         lbl = scales::percent(pct))
## `summarise()` has grouped output by 'Dimensions'. You can override using the `.groups` argument.
library(scales)
theme_set(theme_light(base_size = 12, base_family = "Poppins"))

g<- ggplot(plotdata, 
       aes(x = Dimensions,
           y = pct,
           fill = selection_rec)) +
  geom_bar(stat = "identity",
           position = "fill") +
  scale_y_continuous(breaks = seq(0, 1, .25), 
                     label = percent) +
  geom_text(aes(label = lbl), 
            size = 4, 
            position = position_stack(vjust = 0.5)) +
  scale_fill_brewer(palette = "Pastel1") +
  labs(y = "Percentage", 
       fill = "Selec. Obj.",
       x = "Dimensions",
       title = "2D Context (N = 854)")+
  annotate(geom = "hline",yintercept = 0.5, y = 0.5, color = "black", size = 1, linetype='dotted')+
  annotate("pointrange", x = 1, y = 1 - plotdata_sub$pct, 
           ymin = 1 - plotdata_sub$pct - plotdata_sub$CI, 
           ymax = 1- plotdata_sub$pct + plotdata_sub$CI, 
           colour = "black", size = 0.8, shape = 22, fill = "lightblue", fatten = 1)+
  theme(legend.position = "top", axis.title = element_text(size = 15), axis.text = element_text(size = 13, color = "black"),
        legend.text = element_text(size = 13))
## Warning: Ignoring unknown aesthetics: y
g

#ggsave("selections_2d_main.pdf",width=3.5,height=5)
#ggsave("selections_2d_main.svg",width=3.5,height=5)

Merge all in one data frame (main effect of dimensions)

tdata <- tdata_between

# declare factors and their levels 
tdata$Dimensions <- factor(tdata$Dimensions, levels = c("3D", "2D"), labels = c("3Da", "2D"))

tdata$Transformation <- factor(tdata$Transformation, levels = c("Small", "Angle", "90_rot", "180_rot", "X_sym", "Y_transl", "X_transl"), 
                               labels = c("Size", "Shape", "90-Rot.", "180-Rot.", "X-Sym.", "Y-Tran.","X-Tran."))

tdata$Side <- factor(tdata$Side, levels = c("left", "right"), labels = c("left", "right"))


# recode responses so that 1 = first, 2 = second, 3 = both
tdata$selection_rec <- c(1:length(tdata$sID))
tdata$selection_rec[tdata$Side =="left" & tdata$Value == 1] <- "symm"
tdata$selection_rec[tdata$Side =="left" & tdata$Value == 2] <- "non-symm"
tdata$selection_rec[tdata$Side =="right" & tdata$Value == 1] <- "non-symm"
tdata$selection_rec[tdata$Side =="right" & tdata$Value == 2] <- "symm"



#tdata_strength <-  tdata_strength %>% gather(Entity, Strength, g1:g3, factor_key=TRUE)

 
tdata$selection_rec <- factor(tdata$selection_rec, levels = c("symm", "non-symm"), labels = c("Y-Symm.", "Not-Y-Symm."))

tdata_b <- tdata
tdata <- tdata_within

# declare factors and their levels 
tdata$Dimensions <- factor(tdata$Dimensions, levels = c("3D", "2D"), labels = c("3Db", "2D"))

tdata$Transformation <- factor(tdata$Transformation, levels = c("Small", "Angle", "90_rot", "180_rot", "X_sym", "Y_transl", "X_transl"), 
                               labels = c("Size", "Shape", "90-Rot.", "180-Rot.", "X-Sym.", "Y-Tran.","X-Tran."))

tdata$Side <- factor(tdata$Side, levels = c("left", "right"), labels = c("left", "right"))


# recode responses so that 1 = first, 2 = second, 3 = both
tdata$selection_rec <- c(1:length(tdata$sID))
tdata$selection_rec[tdata$Side =="left" & tdata$Value == 1] <- "symm"
tdata$selection_rec[tdata$Side =="left" & tdata$Value == 2] <- "non-symm"
tdata$selection_rec[tdata$Side =="right" & tdata$Value == 1] <- "non-symm"
tdata$selection_rec[tdata$Side =="right" & tdata$Value == 2] <- "symm"



#tdata_strength <-  tdata_strength %>% gather(Entity, Strength, g1:g3, factor_key=TRUE)

 
tdata$selection_rec <- factor(tdata$selection_rec, levels = c("symm", "non-symm"), labels = c("Y-Symm.", "Not-Y-Symm."))

tdata_w <- tdata
tdata <- tdata_2d

# declare factors and their levels 
tdata$Dimensions <- factor(tdata$Dimensions, levels = c("3D", "2D"), labels = c("3D", "2D"))

tdata$Transformation <- factor(tdata$Transformation, levels = c("Small", "Angle", "90_rot", "180_rot", "X_sym", "Y_transl", "X_transl"), 
                               labels = c("Size", "Shape", "90-Rot.", "180-Rot.", "X-Sym.", "Y-Tran.","X-Tran."))

tdata$Side <- factor(tdata$Side, levels = c("left", "right"), labels = c("left", "right"))


# recode responses so that 1 = first, 2 = second, 3 = both
tdata$selection_rec <- c(1:length(tdata$sID))
tdata$selection_rec[tdata$Side =="left" & tdata$Value == 1] <- "symm"
tdata$selection_rec[tdata$Side =="left" & tdata$Value == 2] <- "non-symm"
tdata$selection_rec[tdata$Side =="right" & tdata$Value == 1] <- "non-symm"
tdata$selection_rec[tdata$Side =="right" & tdata$Value == 2] <- "symm"



#tdata_strength <-  tdata_strength %>% gather(Entity, Strength, g1:g3, factor_key=TRUE)

 
tdata$selection_rec <- factor(tdata$selection_rec, levels = c("symm", "non-symm"), labels = c("Y-Symm.", "Not-Y-Symm."))

tdata_2 <- tdata
tdata <- tdata_manip

# declare factors and their levels 
#tdata$Dimensions <- factor(tdata$Dimensions, levels = c("3D", "2D"), labels = c("3D", "2D"))

tdata$Transformation <- factor(tdata$Transformation, levels = c("Small", "Angle", "90_rot", "180_rot", "X_sym", "Y_transl", "X_transl"), 
                               labels = c("Size", "Shape", "90-Rot.", "180-Rot.", "X-Sym.", "Y-Tran.","X-Tran."))

tdata$Side <- factor(tdata$Side, levels = c("left", "right"), labels = c("left", "right"))


# recode responses so that 1 = first, 2 = second, 3 = both
tdata$selection_rec <- c(1:length(tdata$sID))
tdata$selection_rec[tdata$Side =="left" & tdata$Value == 1] <- "symm"
tdata$selection_rec[tdata$Side =="left" & tdata$Value == 2] <- "non-symm"
tdata$selection_rec[tdata$Side =="right" & tdata$Value == 1] <- "non-symm"
tdata$selection_rec[tdata$Side =="right" & tdata$Value == 2] <- "symm"



#tdata_strength <-  tdata_strength %>% gather(Entity, Strength, g1:g3, factor_key=TRUE)

 
tdata$selection_rec <- factor(tdata$selection_rec, levels = c("symm", "non-symm"), labels = c("Y-Symm.", "Not-Y-Symm."))

tdata_man <- tdata

tdata_man$Side_initial<- c("3D manip.")
tdata_man <- subset(tdata_man, select = c(1,3,4:10,12:13))

colnames(tdata_man)[2] <- "Dimensions"
# combined data frame 
total <- rbind(tdata_b, tdata_w, tdata_man, tdata_2)

total$Dimensions <- factor(total$Dimensions, levels = c("3Da", "3Db", "3D manip.", "2D"), labels = c("3Da", "3Db", "3Dc", "2D"))
# create a summary dataset that also contains the percentages
plotdata_total <- total %>%
  group_by(Dimensions, selection_rec) %>%
  summarize(n = n()) %>% 
  mutate(pct = n/sum(n),
         lbl = scales::percent(pct))
## `summarise()` has grouped output by 'Dimensions'. You can override using the `.groups` argument.

4.5 Plot all in one

library(scales)
theme_set(theme_light(base_size = 10, base_family = "Poppins"))

g<- ggplot(plotdata, 
       aes(x = Dimensions,
           y = pct,
           fill = selection_rec)) +
  geom_bar(stat = "identity",
           position = "fill") +
  scale_y_continuous(limits = seq(0, 2),
                     breaks = seq(0, 1, .25),
                     expand = c(0,0),
                     label = percent) +
  coord_cartesian(xlim =c(1, 4), ylim = c(0, 1.4))+
  #coord_cartesian(clip = "off")+
  geom_text(aes(label = lbl), 
            size = 4, 
            position = position_stack(vjust = 0.5)) +
  scale_fill_brewer(palette = "Pastel1") +
  labs(y = "Percentage", 
       fill = "Selec. Obj.",
       x = "Test condition",
       title = "Subjects' Selections in \n3D vs. 2D Contexts (N = 3430)")+
  #annotate(geom = "hline",yintercept = 0.5, y = 0.5, color = "black", size = 1, linetype='dotted')+
  annotate("pointrange", x = c(1,2,3,4), y = 1 - plotdata_sub$pct, 
           ymin = 1 - plotdata_sub$pct - plotdata_sub$CI, 
           ymax = 1- plotdata_sub$pct + plotdata_sub$CI, 
           colour = "black", size = 0.8, shape = 22, fill = "lightblue", fatten = 1)+
  #annotate("text", x = 1.25, y = Inf, label = "p < .001", size = 4, vjust = 1.6)+
  #annotate("text", x = 2.35, y = Inf, label = "p = .09", size = 4, vjust = 4)+
  theme(legend.position = "top", axis.title = element_text(size = 10), axis.text = element_text(size = 13, color = "black"),
        legend.text = element_text(size = 10),legend.title = element_text(size = 11))+
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())

g

#ggsave("selections_Dim.pdf",width=4,height=5)
#ggsave("selections_Dim.svg",width=6,height=4)

5 Testing the proportions against chance

5.1 Experiment 1a

tdata <- tdata_between

# declare factors and their levels 
tdata$Dimensions <- factor(tdata$Dimensions, levels = c("3D", "2D"), labels = c("3D", "2D"))

tdata$Transformation <- factor(tdata$Transformation, levels = c("Small", "Angle", "90_rot", "180_rot", "X_sym", "Y_transl", "X_transl"), 
                               labels = c("Size", "Shape", "90-Rot.", "180-Rot.", "X-Sym.", "Y-Tran.","X-Tran."))

tdata$Side <- factor(tdata$Side, levels = c("left", "right"), labels = c("left", "right"))


# recode responses so that 1 = first, 2 = second, 3 = both
tdata$selection_rec <- c(1:length(tdata$sID))
tdata$selection_rec[tdata$Side =="left" & tdata$Value == 1] <- "symm"
tdata$selection_rec[tdata$Side =="left" & tdata$Value == 2] <- "non-symm"
tdata$selection_rec[tdata$Side =="right" & tdata$Value == 1] <- "non-symm"
tdata$selection_rec[tdata$Side =="right" & tdata$Value == 2] <- "symm"



#tdata_strength <-  tdata_strength %>% gather(Entity, Strength, g1:g3, factor_key=TRUE)

 
tdata$selection_rec <- factor(tdata$selection_rec, levels = c("symm", "non-symm"), labels = c("Y-Symm.", "Not-Y-Symm."))
# create a summary dataset that also contains the percentages
plotdata_between <- tdata %>%
  group_by(Dimensions, Transformation, selection_rec) %>%
  summarize(n = n()) %>% 
  mutate(pct = n/sum(n),
         lbl = scales::percent(pct))
## `summarise()` has grouped output by 'Dimensions', 'Transformation'. You can override using the `.groups` argument.
plotdata <- plotdata_between
ind <- seq(1, nrow(plotdata), by=2)

plotdata_sub <- plotdata[ind, ]

Binomial-Tests against Chance (50%)

for (i in plotdata_sub$n){
  print(binom.test(i, 122, p = 0.5, alternative = "two.sided"))
}
## 
##  Exact binomial test
## 
## data:  i and 122
## number of successes = 37, number of trials = 122, p-value = 1.649e-05
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.2233437 0.3930317
## sample estimates:
## probability of success 
##              0.3032787 
## 
## 
##  Exact binomial test
## 
## data:  i and 122
## number of successes = 33, number of trials = 122, p-value = 4.04e-07
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.1940711 0.3583898
## sample estimates:
## probability of success 
##              0.2704918 
## 
## 
##  Exact binomial test
## 
## data:  i and 122
## number of successes = 21, number of trials = 122, p-value = 9.678e-14
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.1098244 0.2510049
## sample estimates:
## probability of success 
##              0.1721311 
## 
## 
##  Exact binomial test
## 
## data:  i and 122
## number of successes = 30, number of trials = 122, p-value = 1.647e-08
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.1724670 0.3320671
## sample estimates:
## probability of success 
##              0.2459016 
## 
## 
##  Exact binomial test
## 
## data:  i and 122
## number of successes = 26, number of trials = 122, p-value = 1.261e-10
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.1441863 0.2964618
## sample estimates:
## probability of success 
##              0.2131148 
## 
## 
##  Exact binomial test
## 
## data:  i and 122
## number of successes = 28, number of trials = 122, p-value = 1.577e-09
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.1582472 0.3143412
## sample estimates:
## probability of success 
##              0.2295082 
## 
## 
##  Exact binomial test
## 
## data:  i and 122
## number of successes = 72, number of trials = 122, p-value = 0.05682
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.4974962 0.6783489
## sample estimates:
## probability of success 
##              0.5901639

5.2 Experiment 1b

tdata <- tdata_within

# declare factors and their levels 
tdata$Dimensions <- factor(tdata$Dimensions, levels = c("3D", "2D"), labels = c("3D", "2D"))

tdata$Transformation <- factor(tdata$Transformation, levels = c("Small", "Angle", "90_rot", "180_rot", "X_sym", "Y_transl", "X_transl"), 
                               labels = c("Size", "Shape", "90-Rot.", "180-Rot.", "X-Sym.", "Y-Tran.","X-Tran."))

tdata$Side <- factor(tdata$Side, levels = c("left", "right"), labels = c("left", "right"))


# recode responses so that 1 = first, 2 = second, 3 = both
tdata$selection_rec <- c(1:length(tdata$sID))
tdata$selection_rec[tdata$Side =="left" & tdata$Value == 1] <- "symm"
tdata$selection_rec[tdata$Side =="left" & tdata$Value == 2] <- "non-symm"
tdata$selection_rec[tdata$Side =="right" & tdata$Value == 1] <- "non-symm"
tdata$selection_rec[tdata$Side =="right" & tdata$Value == 2] <- "symm"



#tdata_strength <-  tdata_strength %>% gather(Entity, Strength, g1:g3, factor_key=TRUE)

 
tdata$selection_rec <- factor(tdata$selection_rec, levels = c("symm", "non-symm"), labels = c("Y-Symm.", "Not-Y-Symm."))
# create a summary dataset that also contains the percentages
plotdata_within <- tdata %>%
  group_by(Dimensions, Transformation, selection_rec) %>%
  summarize(n = n()) %>% 
  mutate(pct = n/sum(n),
         lbl = scales::percent(pct))
## `summarise()` has grouped output by 'Dimensions', 'Transformation'. You can override using the `.groups` argument.
plotdata <- plotdata_within
ind <- seq(1, nrow(plotdata), by=2)

plotdata_sub <- plotdata[ind, ]

Binomial-Tests against Chance (50%)

for (i in plotdata_sub$n){
  print(binom.test(i, 122, p = 0.5, alternative = "two.sided"))
}
## 
##  Exact binomial test
## 
## data:  i and 122
## number of successes = 43, number of trials = 122, p-value = 0.001428
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.2681511 0.4441143
## sample estimates:
## probability of success 
##               0.352459 
## 
## 
##  Exact binomial test
## 
## data:  i and 122
## number of successes = 28, number of trials = 122, p-value = 1.577e-09
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.1582472 0.3143412
## sample estimates:
## probability of success 
##              0.2295082 
## 
## 
##  Exact binomial test
## 
## data:  i and 122
## number of successes = 17, number of trials = 122, p-value < 2.2e-16
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.0833176 0.2137055
## sample estimates:
## probability of success 
##              0.1393443 
## 
## 
##  Exact binomial test
## 
## data:  i and 122
## number of successes = 9, number of trials = 122, p-value < 2.2e-16
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.03428627 0.13542190
## sample estimates:
## probability of success 
##             0.07377049 
## 
## 
##  Exact binomial test
## 
## data:  i and 122
## number of successes = 14, number of trials = 122, p-value < 2.2e-16
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.06417694 0.18503849
## sample estimates:
## probability of success 
##              0.1147541 
## 
## 
##  Exact binomial test
## 
## data:  i and 122
## number of successes = 12, number of trials = 122, p-value < 2.2e-16
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.05186499 0.16551339
## sample estimates:
## probability of success 
##             0.09836066 
## 
## 
##  Exact binomial test
## 
## data:  i and 122
## number of successes = 84, number of trials = 122, p-value = 3.792e-05
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.5983838 0.7692605
## sample estimates:
## probability of success 
##              0.6885246

5.3 Experiment 2 (3D with Manip.)

tdata <- tdata_manip

# declare factors and their levels 
#tdata$Dimensions <- factor(tdata$Dimensions, levels = c("3D", "2D"), labels = c("3D", "2D"))

tdata$Transformation <- factor(tdata$Transformation, levels = c("Small", "Angle", "90_rot", "180_rot", "X_sym", "Y_transl", "X_transl"), 
                               labels = c("Size", "Shape", "90-Rot.", "180-Rot.", "X-Sym.", "Y-Tran.","X-Tran."))

tdata$Side <- factor(tdata$Side, levels = c("left", "right"), labels = c("left", "right"))


# recode responses so that 1 = first, 2 = second, 3 = both
tdata$selection_rec <- c(1:length(tdata$sID))
tdata$selection_rec[tdata$Side =="left" & tdata$Value == 1] <- "symm"
tdata$selection_rec[tdata$Side =="left" & tdata$Value == 2] <- "non-symm"
tdata$selection_rec[tdata$Side =="right" & tdata$Value == 1] <- "non-symm"
tdata$selection_rec[tdata$Side =="right" & tdata$Value == 2] <- "symm"



#tdata_strength <-  tdata_strength %>% gather(Entity, Strength, g1:g3, factor_key=TRUE)

 
tdata$selection_rec <- factor(tdata$selection_rec, levels = c("symm", "non-symm"), labels = c("Y-Symm.", "Not-Y-Symm."))
# create a summary dataset that also contains the percentages
plotdata_2d <- tdata %>%
  group_by(Transformation, selection_rec) %>%
  summarize(n = n()) %>% 
  mutate(pct = n/sum(n),
         lbl = scales::percent(pct))
## `summarise()` has grouped output by 'Transformation'. You can override using the `.groups` argument.
plotdata <- plotdata_2d
ind <- seq(1, nrow(plotdata), by=2)

plotdata_sub <- plotdata[ind, ]

Binomial-Tests against Chance (50%)

for (i in plotdata_sub$n){
  print(binom.test(i, 124, p = 0.5, alternative = "two.sided"))
}
## 
##  Exact binomial test
## 
## data:  i and 124
## number of successes = 32, number of trials = 124, p-value = 6.528e-08
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.1836902 0.3443496
## sample estimates:
## probability of success 
##              0.2580645 
## 
## 
##  Exact binomial test
## 
## data:  i and 124
## number of successes = 53, number of trials = 124, p-value = 0.1265
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.3390163 0.5193708
## sample estimates:
## probability of success 
##              0.4274194 
## 
## 
##  Exact binomial test
## 
## data:  i and 124
## number of successes = 38, number of trials = 124, p-value = 1.945e-05
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.2268317 0.3955711
## sample estimates:
## probability of success 
##              0.3064516 
## 
## 
##  Exact binomial test
## 
## data:  i and 124
## number of successes = 43, number of trials = 124, p-value = 0.0008203
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.2635856 0.4374698
## sample estimates:
## probability of success 
##              0.3467742 
## 
## 
##  Exact binomial test
## 
## data:  i and 124
## number of successes = 40, number of trials = 124, p-value = 9.648e-05
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.2414508 0.4124115
## sample estimates:
## probability of success 
##              0.3225806 
## 
## 
##  Exact binomial test
## 
## data:  i and 124
## number of successes = 71, number of trials = 124, p-value = 0.1265
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.4806292 0.6609837
## sample estimates:
## probability of success 
##              0.5725806 
## 
## 
##  Exact binomial test
## 
## data:  i and 124
## number of successes = 62, number of trials = 124, p-value = 1
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.4089093 0.5910907
## sample estimates:
## probability of success 
##                    0.5

5.4 Experiment 3 (2D)

tdata <- tdata_2d

# declare factors and their levels 
tdata$Dimensions <- factor(tdata$Dimensions, levels = c("3D", "2D"), labels = c("3D", "2D"))

tdata$Transformation <- factor(tdata$Transformation, levels = c("Small", "Angle", "90_rot", "180_rot", "X_sym", "Y_transl", "X_transl"), 
                               labels = c("Size", "Shape", "90-Rot.", "180-Rot.", "X-Sym.", "Y-Tran.","X-Tran."))

tdata$Side <- factor(tdata$Side, levels = c("left", "right"), labels = c("left", "right"))


# recode responses so that 1 = first, 2 = second, 3 = both
tdata$selection_rec <- c(1:length(tdata$sID))
tdata$selection_rec[tdata$Side =="left" & tdata$Value == 1] <- "symm"
tdata$selection_rec[tdata$Side =="left" & tdata$Value == 2] <- "non-symm"
tdata$selection_rec[tdata$Side =="right" & tdata$Value == 1] <- "non-symm"
tdata$selection_rec[tdata$Side =="right" & tdata$Value == 2] <- "symm"



#tdata_strength <-  tdata_strength %>% gather(Entity, Strength, g1:g3, factor_key=TRUE)

 
tdata$selection_rec <- factor(tdata$selection_rec, levels = c("symm", "non-symm"), labels = c("Y-Symm.", "Not-Y-Symm."))
# create a summary dataset that also contains the percentages
plotdata_2d <- tdata %>%
  group_by(Dimensions, Transformation, selection_rec) %>%
  summarize(n = n()) %>% 
  mutate(pct = n/sum(n),
         lbl = scales::percent(pct))
## `summarise()` has grouped output by 'Dimensions', 'Transformation'. You can override using the `.groups` argument.
plotdata <- plotdata_2d
ind <- seq(1, nrow(plotdata), by=2)

plotdata_sub <- plotdata[ind, ]

Binomial-Tests against Chance (50%)

for (i in plotdata_sub$n){
  print(binom.test(i, 122, p = 0.5, alternative = "two.sided"))
}
## 
##  Exact binomial test
## 
## data:  i and 122
## number of successes = 60, number of trials = 122, p-value = 0.9279
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.4001674 0.5838464
## sample estimates:
## probability of success 
##              0.4918033 
## 
## 
##  Exact binomial test
## 
## data:  i and 122
## number of successes = 41, number of trials = 122, p-value = 0.0003714
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.2531022 0.4271979
## sample estimates:
## probability of success 
##              0.3360656 
## 
## 
##  Exact binomial test
## 
## data:  i and 122
## number of successes = 32, number of trials = 122, p-value = 1.449e-07
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.1868347 0.3496496
## sample estimates:
## probability of success 
##              0.2622951 
## 
## 
##  Exact binomial test
## 
## data:  i and 122
## number of successes = 45, number of trials = 122, p-value = 0.004801
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.2833077 0.4609245
## sample estimates:
## probability of success 
##              0.3688525 
## 
## 
##  Exact binomial test
## 
## data:  i and 122
## number of successes = 52, number of trials = 122, p-value = 0.1234
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.3371629 0.5189628
## sample estimates:
## probability of success 
##              0.4262295 
## 
## 
##  Exact binomial test
## 
## data:  i and 122
## number of successes = 73, number of trials = 122, p-value = 0.03688
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.5057622 0.6860679
## sample estimates:
## probability of success 
##              0.5983607 
## 
## 
##  Exact binomial test
## 
## data:  i and 122
## number of successes = 66, number of trials = 122, p-value = 0.4153
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.4484068 0.6315242
## sample estimates:
## probability of success 
##              0.5409836

Combined:

# create a summary dataset that also contains the percentages
plotdata_total <- total %>%
  group_by(Dimensions, selection_rec) %>%
  summarize(n = n()) %>% 
  mutate(pct = n/sum(n),
         lbl = scales::percent(pct))
## `summarise()` has grouped output by 'Dimensions'. You can override using the `.groups` argument.

6 Test the contexts against each other

6.1 Test 3Da against 3Db

test3Da_3Db <- prop.test(x = c(plotdata_sub$n[1], plotdata_sub$n[2]), n = c(854, 854))
test3Da_3Db
## 
##  2-sample test for equality of proportions with continuity correction
## 
## data:  c(plotdata_sub$n[1], plotdata_sub$n[2]) out of c(854, 854)
## X-squared = 4.5631, df = 1, p-value = 0.03267
## alternative hypothesis: two.sided
## 95 percent confidence interval:
##  0.003825503 0.089851312
## sample estimates:
##    prop 1    prop 2 
## 0.2892272 0.2423888

6.2 Test 3Da against 3D with manip

test3Da_3Dmanip <- prop.test(x = c(plotdata_sub$n[1], plotdata_sub$n[3]), n = c(854, 868))
test3Da_3Dmanip
## 
##  2-sample test for equality of proportions with continuity correction
## 
## data:  c(plotdata_sub$n[1], plotdata_sub$n[3]) out of c(854, 868)
## X-squared = 19.238, df = 1, p-value = 1.154e-05
## alternative hypothesis: two.sided
## 95 percent confidence interval:
##  -0.14696333 -0.05568833
## sample estimates:
##    prop 1    prop 2 
## 0.2892272 0.3905530

6.3 Test 3Db against 3D with manip

test3Db_3Dmanip <- prop.test(x = c(plotdata_sub$n[2], plotdata_sub$n[3]), n = c(854, 868))
test3Db_3Dmanip
## 
##  2-sample test for equality of proportions with continuity correction
## 
## data:  c(plotdata_sub$n[2], plotdata_sub$n[3]) out of c(854, 868)
## X-squared = 42.96, df = 1, p-value = 5.588e-11
## alternative hypothesis: two.sided
## 95 percent confidence interval:
##  -0.1926782 -0.1036503
## sample estimates:
##    prop 1    prop 2 
## 0.2423888 0.3905530

6.4 Test 3D with manip against 2D

test3Dmanip_2D <- prop.test(x = c(plotdata_sub$n[3], plotdata_sub$n[4]), n = c(868, 854))
test3Dmanip_2D
## 
##  2-sample test for equality of proportions with continuity correction
## 
## data:  c(plotdata_sub$n[3], plotdata_sub$n[4]) out of c(868, 854)
## X-squared = 2.8977, df = 1, p-value = 0.08871
## alternative hypothesis: two.sided
## 95 percent confidence interval:
##  -0.089138481  0.006075854
## sample estimates:
##    prop 1    prop 2 
## 0.3905530 0.4320843