First, we load our libraries:
library(tidyverse)
library(ggeasy)
library(ggbeeswarm)
library(patchwork)
Next, loading the data file for Experiment 2:
exptwo <- "Study 7 data.csv" %>%
read_csv() %>%
rename(
recall_score = SC0, #nicer name for recall score
condition = FL_12_DO #nicer name for condition
)
exptwo <- exptwo %>%
slice(-1:-2) %>%
select(Consent, Finished, Gender, Age, NC_1:condition)
glimpse(exptwo)
## Rows: 412
## Columns: 39
## $ Consent <chr> "1", "1", "1", "1", "1", "1", "1", "1", "1", "1…
## $ Finished <chr> "1", "1", "1", "1", "1", "1", "1", "1", "1", "1…
## $ Gender <chr> "2", "1", "2", "2", "1", "1", "2", "2", "2", "2…
## $ Age <chr> "51", "19", "31", "32", "49", "20", "20", "29",…
## $ NC_1 <chr> "2", "2", "2", "5", "4", "4", "4", "1", "4", "4…
## $ NC_2 <chr> "2", "2", "1", "4", "4", "4", "4", "1", "4", "4…
## $ NC_3 <chr> "2", "2", "1", "3", "4", "3", "2", "4", "2", "2…
## $ NC_4 <chr> "2", "4", "2", "4", "4", "4", "5", "1", "4", "4…
## $ NC_5 <chr> "2", "3", "2", "2", "4", "2", "4", "4", "2", "2…
## $ NC_6 <chr> "1", "3", "2", "2", "4", "2", "2", "4", "2", "2…
## $ NBS_1 <chr> "2", "5", "1", "4", "4", "4", "5", "3", "4", "5…
## $ NBS_2 <chr> "2", "3", "2", "4", "2", "4", "4", "4", "2", "2…
## $ NBS_3 <chr> "2", "2", "2", "4", "2", "5", "4", "4", "2", "2…
## $ NBS_4 <chr> "1", "2", "2", "3", "2", "1", "1", "2", "2", "1…
## $ NBS_5 <chr> "1", "2", "2", "3", "2", "1", "2", "2", "2", "2…
## $ NBS_6 <chr> "1", "4", "2", "4", "2", "2", "5", "2", "4", "4…
## $ Mistrust_expertise_1 <chr> "2", "2", "1", "3", "2", "2", "3", "1", "3", "2…
## $ Mistrust_expertise_2 <chr> "2", "1", "1", "2", "1", "1", "2", "1", "3", "3…
## $ Mistrust_expertise_3 <chr> "2", "2", "5", "3", "2", "1", "4", "2", "2", "2…
## $ GSS <chr> "1", "1", "1", "2", "1", "1", "2", "1", "2", "2…
## $ Certainty_sci_know_1 <chr> "4", "5", "5", "3", "4", "4", "5", "2", "4", "5…
## $ Certainty_sci_know_2 <chr> "2", "3", "4", "2", "2", "3", "5", "1", "4", "2…
## $ Certainty_sci_know_3 <chr> "4", "5", "5", "4", "5", "5", "5", "5", "3", "4…
## $ Certainty_sci_know_4 <chr> "4", "5", "3", "3", "2", "3", "5", "4", "4", "2…
## $ Certainty_sci_know_5 <chr> "4", "5", "5", "5", "5", "4", "5", "3", "4", "4…
## $ Certainty_sci_know_6 <chr> "4", "5", "5", "5", "4", "4", "4", "5", "3", "2…
## $ Development_sci_know_1 <chr> "4", "5", "5", "5", "4", "5", "5", "5", "4", "5…
## $ Development_sci_know_2 <chr> "4", "4", "5", "4", "5", "5", "5", "5", "4", "5…
## $ Development_sci_know_3 <chr> "4", "5", "5", "4", "4", "5", "4", "5", "5", "5…
## $ Development_sci_know_4 <chr> "4", "4", "5", "4", "5", "5", "5", "5", "5", "5…
## $ Development_sci_know_5 <chr> "5", "5", "5", "4", "5", "5", "5", "5", "5", "5…
## $ Development_sci_know_6 <chr> "5", "4", "5", "4", "4", "5", "4", "5", "4", "4…
## $ Memory_task <chr> "1", "1", "1", "1", "1", "1", "1", "1", "1", "1…
## $ Memory_task_DO <chr> "0|1|0|1|1|0|0|1|1|0|0|1|0|1", "0|0|1|1|1|0|1|1…
## $ Serious_check <chr> "1", "1", "1", "1", "1", "1", "1", "1", "1", "1…
## $ recall_score <chr> "7", "7", "7", "7", "7", "7", "7", "7", "7", "7…
## $ Prolific_PID <chr> "5ecad11f815ac263a27af2ad", "5e6da5dfe02fac3787…
## $ Random_ID <chr> "8661", "8637", "1981", "1161", "9486", "5462",…
## $ condition <chr> "Block_3_Qualified_Conflict", "Block_3_Qualifie…
exptwo$Prolific_PID[duplicated(exptwo$Prolific_PID)]
## [1] "5b8800b14fe6450001f07d71" "5ae8d7b596845f0001c7948d"
## [3] "5e68d2b5576136000ba058a2"
exptwo <- exptwo[!duplicated(exptwo$Prolific_PID), ]
I am creating this final data set as an object called ‘exptwofinaldata’
exptwofinaldata <- exptwo %>%
filter(
Consent == "1", #filter to include those who consented
Finished == "1", #filter to include those who Finished
Serious_check == "1", #filter to include those who answered they passed Serious Check
recall_score >= "4", #filter to include recalls core 4 and above only
)
exptwofinaldata %>%
count (Consent)
## # A tibble: 1 x 2
## Consent n
## <chr> <int>
## 1 1 400
According to the paper:
exptwofinaldata$Gender <- as.factor(exptwofinaldata$Gender)
exptwofinaldata %>%
mutate(
Gender = case_when(
Gender == 1 ~ "Male",
Gender == 2 ~ "Female"
)
)
## # A tibble: 400 x 39
## Consent Finished Gender Age NC_1 NC_2 NC_3 NC_4 NC_5 NC_6 NBS_1 NBS_2
## <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 1 1 Female 51 2 2 2 2 2 1 2 2
## 2 1 1 Male 19 2 2 2 4 3 3 5 3
## 3 1 1 Female 31 2 1 1 2 2 2 1 2
## 4 1 1 Female 32 5 4 3 4 2 2 4 4
## 5 1 1 Male 49 4 4 4 4 4 4 4 2
## 6 1 1 Male 20 4 4 3 4 2 2 4 4
## 7 1 1 Female 20 4 4 2 5 4 2 5 4
## 8 1 1 Female 29 1 1 4 1 4 4 3 4
## 9 1 1 Female 29 4 4 2 4 2 2 4 2
## 10 1 1 Female 18 4 4 2 4 2 2 5 2
## # … with 390 more rows, and 27 more variables: NBS_3 <chr>, NBS_4 <chr>,
## # NBS_5 <chr>, NBS_6 <chr>, Mistrust_expertise_1 <chr>,
## # Mistrust_expertise_2 <chr>, Mistrust_expertise_3 <chr>, GSS <chr>,
## # Certainty_sci_know_1 <chr>, Certainty_sci_know_2 <chr>,
## # Certainty_sci_know_3 <chr>, Certainty_sci_know_4 <chr>,
## # Certainty_sci_know_5 <chr>, Certainty_sci_know_6 <chr>,
## # Development_sci_know_1 <chr>, Development_sci_know_2 <chr>,
## # Development_sci_know_3 <chr>, Development_sci_know_4 <chr>,
## # Development_sci_know_5 <chr>, Development_sci_know_6 <chr>,
## # Memory_task <chr>, Memory_task_DO <chr>, Serious_check <chr>,
## # recall_score <chr>, Prolific_PID <chr>, Random_ID <chr>, condition <chr>
exptwofinaldata %>%
count(Gender)
## # A tibble: 3 x 2
## Gender n
## <fct> <int>
## 1 1 150
## 2 2 248
## 3 3 2
exptwofinaldata$Age <- as.numeric(exptwofinaldata$Age)
exptwofinaldata %>%
summarise(
Mean = mean(Age),
SD = sd(Age),
Min = min(Age),
Max = max(Age)
) %>%
as.data.frame()
## Mean SD Min Max
## 1 33.465 12.03415 18 73
exptwofinaldata <- separate(data = exptwofinaldata, col = condition, into = c("block", "number", "format", "conflict"))
exptwofinaldata$format <- as.factor(exptwofinaldata$format)
exptwofinaldata$conflict <- as.factor(exptwofinaldata$conflict)
# Calculate participants' average scores as a new variable for each of the 6 variables studied
exptwofinaldata$NC_1 <- as.numeric(exptwofinaldata$NC_1)
exptwofinaldata$NC_2 <- as.numeric(exptwofinaldata$NC_2)
exptwofinaldata$NC_3 <- as.numeric(exptwofinaldata$NC_3)
exptwofinaldata$NC_4 <- as.numeric(exptwofinaldata$NC_4)
exptwofinaldata$NC_5 <- as.numeric(exptwofinaldata$NC_5)
exptwofinaldata$NC_6 <- as.numeric(exptwofinaldata$NC_6)
exptwofinaldata$NBS_1 <- as.numeric(exptwofinaldata$NBS_1)
exptwofinaldata$NBS_2 <- as.numeric(exptwofinaldata$NBS_2)
exptwofinaldata$NBS_3 <- as.numeric(exptwofinaldata$NBS_3)
exptwofinaldata$NBS_4 <- as.numeric(exptwofinaldata$NBS_4)
exptwofinaldata$NBS_5 <- as.numeric(exptwofinaldata$NBS_5)
exptwofinaldata$NBS_6 <- as.numeric(exptwofinaldata$NBS_6)
exptwofinaldata$Mistrust_expertise_1 <- as.numeric(exptwofinaldata$Mistrust_expertise_1)
exptwofinaldata$Mistrust_expertise_2 <- as.numeric(exptwofinaldata$Mistrust_expertise_2)
exptwofinaldata$Mistrust_expertise_3 <- as.numeric(exptwofinaldata$Mistrust_expertise_3)
exptwofinaldata$GSS <- as.numeric(exptwofinaldata$GSS)
exptwofinaldata$Certainty_sci_know_1 <- as.numeric(exptwofinaldata$Certainty_sci_know_1)
exptwofinaldata$Certainty_sci_know_2 <- as.numeric(exptwofinaldata$Certainty_sci_know_2)
exptwofinaldata$Certainty_sci_know_3 <- as.numeric(exptwofinaldata$Certainty_sci_know_3)
exptwofinaldata$Certainty_sci_know_4 <- as.numeric(exptwofinaldata$Certainty_sci_know_4)
exptwofinaldata$Certainty_sci_know_5 <- as.numeric(exptwofinaldata$Certainty_sci_know_5)
exptwofinaldata$Certainty_sci_know_6 <- as.numeric(exptwofinaldata$Certainty_sci_know_6)
exptwofinaldata$Development_sci_know_1 <- as.numeric(exptwofinaldata$Development_sci_know_1)
exptwofinaldata$Development_sci_know_2 <- as.numeric(exptwofinaldata$Development_sci_know_2)
exptwofinaldata$Development_sci_know_3 <- as.numeric(exptwofinaldata$Development_sci_know_3)
exptwofinaldata$Development_sci_know_4 <- as.numeric(exptwofinaldata$Development_sci_know_4)
exptwofinaldata$Development_sci_know_5 <- as.numeric(exptwofinaldata$Development_sci_know_5)
exptwofinaldata$Development_sci_know_6 <- as.numeric(exptwofinaldata$Development_sci_know_6)
exptwofinaldata <- exptwofinaldata %>%
mutate (
confusion = ((exptwofinaldata$NC_1 + exptwofinaldata$NC_2 + exptwofinaldata$NC_3 + exptwofinaldata$NC_4 + exptwofinaldata$NC_5 + exptwofinaldata$NC_6)/6),
backlash = ((exptwofinaldata$NBS_1 + exptwofinaldata$NBS_2 + exptwofinaldata$NBS_3 + exptwofinaldata$NBS_4 + exptwofinaldata$NBS_5 + exptwofinaldata$NBS_6)/6),
mistrust = ((exptwofinaldata$Mistrust_expertise_1 + exptwofinaldata$Mistrust_expertise_2 + exptwofinaldata$Mistrust_expertise_3)/3),
confidence = exptwofinaldata$GSS,
certainty = ((exptwofinaldata$Certainty_sci_know_1 + exptwofinaldata$Certainty_sci_know_2 + exptwofinaldata$Certainty_sci_know_3 + exptwofinaldata$Certainty_sci_know_4 + exptwofinaldata$Certainty_sci_know_5 + exptwofinaldata$Certainty_sci_know_6)/6),
development = ((exptwofinaldata$Development_sci_know_1 + exptwofinaldata$Development_sci_know_2 + exptwofinaldata$Development_sci_know_3 + exptwofinaldata$Development_sci_know_4 + exptwofinaldata$Development_sci_know_5 + exptwofinaldata$Development_sci_know_6)/6)
)
exptwofinaldata %>%
select(format:development)
## # A tibble: 400 x 8
## format conflict confusion backlash mistrust confidence certainty development
## <fct> <fct> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 Qualif… Conflict 1.83 1.5 2 1 3.67 4.33
## 2 Qualif… Conflict 2.67 3 1.67 1 4.67 4.5
## 3 Qualif… Consist… 1.67 1.83 2.33 1 4.5 5
## 4 Generic Conflict 3.33 3.67 2.67 2 3.67 4.17
## 5 Generic Conflict 4 2.33 1.67 1 3.67 4.5
## 6 Generic Consist… 3.17 2.83 1.33 1 3.83 5
## 7 Qualif… Consist… 3.5 3.5 3 2 4.83 4.67
## 8 Generic Consist… 2.5 2.83 1.33 1 3.33 5
## 9 Generic Consist… 3 2.67 2.67 2 3.67 4.5
## 10 Generic Conflict 3 2.67 2.33 2 3.17 4.83
## # … with 390 more rows
confusion <- ggplot(
data = exptwofinaldata,
aes(
x = conflict,
y = confusion,
fill = conflict
)
) +
geom_violin() +
facet_wrap(
vars(format),
strip.position = "bottom" #moves strip to bottom
) +
stat_summary(
fun.data = "mean_cl_normal",
geom = "crossbar", #specifying we want crossbars
fill = "white", #changing crossbar fill colour
alpha = .7 #changes transparency of fill to 70%
) +
geom_beeswarm(
cex = 0.2 #add a bee swarm plot (one-dimensional scatter plot) to show all data points, cex specified width
) +
ggtitle(
label = "Nutritional Confusion"
) +
easy_center_title() +
easy_remove_legend() +
easy_remove_x_axis(
what = c("title")
) +
scale_y_continuous(
name = "Nutritional Confusion"
) +
scale_fill_manual(
values = c("slategray2", "lightpink1") #change violin plot fill colours
)
plot(confusion)
backlash <- ggplot(
data = exptwofinaldata,
aes(
x = conflict,
y = backlash,
fill = conflict
)
) +
geom_violin() +
facet_wrap(
vars(format),
strip.position = "bottom" #moves strip to bottom
) +
stat_summary(
fun.data = "mean_cl_normal",
geom = "crossbar", #specifying we want crossbars
fill = "white", #changing crossbar fill colour
alpha = .7 #changes transparency of fill to 70%
) +
geom_beeswarm(
cex = 0.2 #add a bee swarm plot (one-dimensional scatter plot) to show all data points, cex specified width
) +
ggtitle(
label = "Nutritional Backlash"
) +
easy_center_title() +
easy_remove_legend() +
easy_remove_x_axis(
what = c("title")
) +
scale_y_continuous(
name = "Nutritional Backlash"
) +
scale_fill_manual(
values = c("slategray2", "lightpink1") #change violin plot fill colours
)
plot(backlash)
mistrust <- ggplot(
data = exptwofinaldata,
aes(
x = conflict,
y = mistrust,
fill = conflict
)
) +
geom_violin() +
facet_wrap(
vars(format),
strip.position = "bottom" #moves strip to bottom
) +
stat_summary(
fun.data = "mean_cl_normal",
geom = "crossbar", #specifying we want crossbars
fill = "white", #changing crossbar fill colour
alpha = .7 #changes transparency of fill to 70%
) +
geom_beeswarm(
cex = 0.2 #add a bee swarm plot (one-dimensional scatter plot) to show all data points, cex specified width
) +
ggtitle(
label = "Mistrust of Expertise"
) +
easy_center_title() +
easy_remove_legend() +
easy_remove_x_axis(
what = c("title")
) +
scale_y_continuous(
name = "Mistrust of Expertise"
) +
scale_fill_manual(
values = c("slategray2", "lightpink1") #change violin plot fill colours
)
plot(mistrust)
confidence <- ggplot(
data = exptwofinaldata,
aes(
x = conflict,
y = confidence,
fill = conflict
)
) +
geom_violin() +
facet_wrap(
vars(format),
strip.position = "bottom" #moves strip to bottom
) +
stat_summary(
fun.data = "mean_cl_normal",
geom = "crossbar", #specifying we want crossbars
fill = "white", #changing crossbar fill colour
alpha = .7 #changes transparency of fill to 70%
) +
geom_beeswarm(
cex = 0.2 #add a bee swarm plot (one-dimensional scatter plot) to show all data points, cex specified width
) +
ggtitle(
label = "Confidence in Scientific Community"
) +
easy_center_title() +
easy_remove_legend() +
easy_remove_x_axis(
what = c("title")
) +
scale_y_continuous(
name = "Confidence in Scientific Community"
) +
scale_fill_manual(
values = c("slategray2", "lightpink1") #change violin plot fill colours
)
plot(confidence)
certainty <- ggplot(
data = exptwofinaldata,
aes(
x = conflict,
y = certainty,
fill = conflict
)
) +
geom_violin() +
facet_wrap(
vars(format),
strip.position = "bottom" #moves strip to bottom
) +
stat_summary(
fun.data = "mean_cl_normal",
geom = "crossbar", #specifying we want crossbars
fill = "white", #changing crossbar fill colour
alpha = .7 #changes transparency of fill to 70%
) +
geom_beeswarm(
cex = 0.2 #add a bee swarm plot (one-dimensional scatter plot) to show all data points, cex specified width
) +
ggtitle(
label = "Certainty of Knowledge"
) +
easy_center_title() +
easy_remove_legend() +
easy_remove_x_axis(
what = c("title")
) +
scale_y_continuous(
name = "Certainty of Knowledge"
) +
scale_fill_manual(
values = c("slategray2", "lightpink1") #change violin plot fill colours
)
plot(certainty)
development <- ggplot(
data = exptwofinaldata,
aes(
x = conflict,
y = development,
fill = conflict
)
) +
geom_violin() +
facet_wrap(
vars(format),
strip.position = "bottom" #moves strip to bottom
) +
stat_summary(
fun.data = "mean_cl_normal",
geom = "crossbar", #specifying we want crossbars
fill = "white", #changing crossbar fill colour
alpha = .7 #changes transparency of fill to 70%
) +
geom_beeswarm(
cex = 0.2 #add a bee swarm plot (one-dimensional scatter plot) to show all data points, cex specified width
) +
ggtitle(
label = "Development of Knowledge"
) +
easy_center_title() +
easy_remove_legend() +
easy_remove_x_axis(
what = c("title")
) +
scale_y_continuous(
name = "Development of Knowledge"
) +
scale_fill_manual(
values = c("slategray2", "lightpink1") #change violin plot fill colours
)
plot(development)
I am using the patchwork package’s plot_layout function to put all plots together.
combinedplot2 <- confusion + backlash + mistrust + confidence + certainty + development + plot_layout(ncol = 2)
plot (combinedplot2)