knitr::opts_chunk$set(warning =FALSE, message =FALSE) Mypackages <-c("lme4","tidyverse","effects","ggplot2","psych","MASS","Rmisc","lmerTest","ggthemes", "knitr","lsmeans","pastecs","sjstats","car","ordinal","Rcpp","corrplot", "ggpubr", "EnvStats","easyStats", "cowplot","see","datawizard", "ggcorrplot", "lavaan", "scales")#install.packages(Mypackages) #you must remove the # in this comment if you need to install the packages! lapply(Mypackages, require,character.only =TRUE)options(knitr.kable.NA ='—')set.seed(1)
Load Data
Code
# read in data filessetwd("~/Desktop")data_raw <-read.csv("/Users/mtrenfield17/Desktop/Research/Boston College Research/Morality Lab Research/Phantom Rules Close Others/PILOT 1 Close Relationship Phantom Rules.csv")
Functions
Code
plot_cooker <-function(data, iv, dv) { part1 <-ggplot(data, aes(x = {{iv}}, y = {{dv}}, fill = {{iv}})) +geom_violin(alpha =0.3, scale ="count") +stat_summary(fun ="mean", geom ="point", size =3, color ="black") +stat_summary(fun.data = mean_cl_normal, geom ="errorbar", width =0.2,#change to make a data set from allEffects with mean, low CI, high CIsize =1.5, color ="black") +theme_classic() +xlab("") +ylab("")ggpar(part1, legend ="none")}pol_line <-function(data, iv, dv) {ggplot(data, aes(x = {{iv}}, y = {{dv}}, color = condition)) +stat_summary(fun.data ="mean_cl_normal", geom ="line") +geom_point(position =position_jitter(width =0.1, height =0.1), alpha =0.5) +labs(x ="Political Leaning", color ="Condition")}lizy_cooker <-function(dv, iv, Title, x_axis_labs, y_label, sample_size, coln, rown) { part1 <-ggviolin(gjg, x = dv, y = iv, color = dv,alpha =0.1, fill = dv, xlab ="Motive",trim =TRUE, ylab = y_label) +stat_summary(fun.data ="mean_cl_normal", geom ="crossbar", fatten =1) +scale_y_continuous(breaks =c(1:7)) +labs(title =paste0(Title, " (n = ", sample_size, ")")) +theme(panel.background =element_rect(fill ="transparent"), legend.position ="right", ## Consider “gray97” for fillplot.title =element_text(face ="bold", hjust =0.5, size =16), plot.subtitle =element_text(hjust =0.5),panel.grid.major.y =element_line(color='grey75'), axis.text.x =element_text(face ="plain", size =13, color ="black"),axis.text.y =element_text(face ="plain", size =13, color ="black"),axis.title.y =element_text(face ="plain", size =13, color ="black", margin =margin(t =0, r =10, b =0, l =0)), ## lower X axis titlepanel.border =element_rect(color ="black", fill =NA, size =1)) +scale_color_discrete(name ="Condition") +facet_wrap(~ vignette, ncol = coln, nrow = rown, scales ="free", as.table =TRUE)ggpar(part1, legend ="none")}#POL_gjg_long <- filter(gjg_long, political_overall %in% c("Democrat", "Republican"))#gjg_long$political_overall#ggplot(gjg_long, aes(x = condition, y = p_approve, color = condition)) +#geom_point(stat="summary", fun="mean", size = 2) +#facet_wrap(~political_overall) +#scale_x_discrete(labels = NULL)
Reshaping data
Code
# fixing typodata_raw$close1_code <-gsub("Romatic partner", "Romantic partner", data_raw$close1_code)data_raw$close2_code <-gsub("Romatic partner", "Romantic partner", data_raw$close2_code)data_raw$close3_code <-gsub("Romatic partner", "Romantic partner", data_raw$close3_code)# making conservative, liberal, and moderate group data_raw <- data_raw %>%mutate(political_group =ifelse(Political_overall >4, "Conservative",ifelse(Political_overall <4, "Liberal", "Moderate")))# making a column for white vs non-whitedata_raw$White <-ifelse(grepl("White", data_raw$Race_Ethnicity_TEXT), "White", "Non-White")# making a column for URM vs non-URMurm_groups <-c("Black", "Hispanic or Latino/a/x", "American Indian and Native Alaskan", "Pacific Islander or Native Hawaiian", "Middle Eastern and North African")data_raw$URM <-ifelse(grepl(paste(urm_groups, collapse="|"), data_raw$Race_Ethnicity_TEXT), "URM", "Non-URM")#### filtering people who failed the attn check ####data_raw$attn_self <-as.numeric(data_raw$attn_self)data <- data_raw %>%filter(attn_self >2)# Removing low quality datadata <- data %>%filter(!(prolificID %in%c("66574c6a2a79bcd8ac8a00e8", "662d15c45fc2c1ca89b362bf")))# changing numeric DVs to numericdata <- data %>%mutate_at(vars(loiter_interaction:jay_fair, Age), as.numeric)#### make dataset long ###data_long <- data %>%gather(stim, resp, "loiter_interaction":"jay_fair")data_long<-data_long %>%separate(stim, into=c("scenario", "DV"), sep="_")## shift dataset back to wide format ##data_long <-spread(data_long, DV, resp)# seperating the scenario order into their own columnsdata_long <- data_long %>%separate(scenario_order, into=c("first_scenario", "second_scenario", "third_scenario", "fourth_scenario", "fifth_scenario", "sixth_scenario"), sep="\\|")# renaming scenariosdata_long <- data_long %>%mutate(first_scenario =case_when( first_scenario =="FL_60"~"loiter", first_scenario =="FL_59"~"brights", first_scenario =="FL_57"~"jury", first_scenario =="FL_58"~"noise", first_scenario =="FL_56"~"music", first_scenario =="FL_55"~"jay",TRUE~ scenario))data_long <- data_long %>%mutate(second_scenario =case_when( second_scenario =="FL_60"~"loiter", second_scenario =="FL_59"~"brights", second_scenario =="FL_57"~"jury", second_scenario =="FL_58"~"noise", second_scenario =="FL_56"~"music", second_scenario =="FL_55"~"jay",TRUE~ scenario))data_long <- data_long %>%mutate(third_scenario =case_when( third_scenario =="FL_60"~"loiter", third_scenario =="FL_59"~"brights", third_scenario =="FL_57"~"jury", third_scenario =="FL_58"~"noise", third_scenario =="FL_56"~"music", third_scenario =="FL_55"~"jay",TRUE~ scenario))data_long <- data_long %>%mutate(fourth_scenario =case_when( fourth_scenario =="FL_60"~"loiter", fourth_scenario =="FL_59"~"brights", fourth_scenario =="FL_57"~"jury", fourth_scenario =="FL_58"~"noise", fourth_scenario =="FL_56"~"music", fourth_scenario =="FL_55"~"jay",TRUE~ scenario))data_long <- data_long %>%mutate(fifth_scenario =case_when( fifth_scenario =="FL_60"~"loiter", fifth_scenario =="FL_59"~"brights", fifth_scenario =="FL_57"~"jury", fifth_scenario =="FL_58"~"noise", fifth_scenario =="FL_56"~"music", fifth_scenario =="FL_55"~"jay",TRUE~ scenario))data_long <- data_long %>%mutate(sixth_scenario =case_when( sixth_scenario =="FL_60"~"loiter", sixth_scenario =="FL_59"~"brights", sixth_scenario =="FL_57"~"jury", sixth_scenario =="FL_58"~"noise", sixth_scenario =="FL_56"~"music", sixth_scenario =="FL_55"~"jay",TRUE~ scenario))# column for order the scenario was seendata_long <- data_long %>%mutate(presentation_order =case_when( scenario == first_scenario ~"first", scenario == second_scenario ~"second", scenario == third_scenario ~"third", scenario == fourth_scenario ~"fourth", scenario == fifth_scenario ~"fifth", scenario == sixth_scenario ~"sixth",TRUE~"not found" ))# column for whether the target was a stranger or close otherdata_long <- data_long %>%mutate(relationship =case_when( presentation_order =="first"& color_1 =="#FF5733"~"stranger", presentation_order =="first"& color_1 =="blue"~"close other", presentation_order =="second"& color_2 =="#FF5733"~"stranger", presentation_order =="second"& color_2 =="blue"~"close other", presentation_order =="third"& color_3 =="#FF5733"~"stranger", presentation_order =="third"& color_3 =="blue"~"close other", presentation_order =="fourth"& color_4 =="#FF5733"~"stranger", presentation_order =="fourth"& color_4 =="blue"~"close other", presentation_order =="fifth"& color_5 =="#FF5733"~"stranger", presentation_order =="fifth"& color_5 =="blue"~"close other", presentation_order =="sixth"& color_6 =="#FF5733"~"stranger", presentation_order =="sixth"& color_6 =="blue"~"close other",TRUE~"unknown" ))data_long <- data_long %>%mutate(corresponding_name =case_when( presentation_order =="first"~ name_1, presentation_order =="second"~ name_2, presentation_order =="third"~ name_3, presentation_order =="fourth"~ name_4, presentation_order =="fifth"~ name_5, presentation_order =="sixth"~ name_6,TRUE~NA_character_ ) )# Assign the appropriate relationship code or label as "stranger"data_long <- data_long %>%mutate(relationship_code =case_when( corresponding_name == close1_name ~ close1_code, corresponding_name == close2_name ~ close2_code, corresponding_name == close3_name ~ close3_code,TRUE~"stranger" ) )# column for how much participants like the close otherdata_long <- data_long %>%mutate(likeClose =case_when( corresponding_name == close1_name ~ likeClose1_1, corresponding_name == close2_name ~ likeClose2_1, corresponding_name == close3_name ~ likeClose3_1,TRUE~"n/a" ) )# making factor variables factorsdata_long <- data_long %>%mutate_at(vars(confront,didBreak,interaction, order,Gender), as.factor)
# putting the demos in the right orderdata <- data %>%mutate(Gender_TEXT =factor(Gender_TEXT, levels =c("Man", "Woman", "Nonbinary person", "An identity not listed")),Political_overall_TEXT =factor(Political_overall_TEXT, levels =c("Very liberal", "Liberal", "Somewhat liberal", "Moderate", "Somewhat conservative", "Conservative", "Very conservative")),political_group =factor(political_group, levels =c("Liberal", "Moderate", "Conservative")),White =factor(White, levels =c("White", "Non-White")),URM =factor(URM, levels =c("Non-URM", "URM")) )# Subset your data frame to include only the demographic columnsdemo_data <- data[, c("Gender_TEXT", "Race_Ethnicity_TEXT", "Political_overall_TEXT", "political_group", "White", "URM")]# Agemean(data$Age, na.rm=TRUE)
[1] 37.16892
Code
sd(data$Age, na.rm=TRUE)
[1] 10.84108
Code
# Loop through each demographic column and calculate frequency countsfreq_tables <-list()for (col innames(demo_data)) { { freq_table <-as.data.frame(table(demo_data[[col]])) freq_table$Percent <-round(freq_table$Freq /sum(freq_table$Freq) *100, 2) freq_tables[[col]] <- freq_table }}# Print the frequency tablesfor (i inseq_along(freq_tables)) {if (!is.null(freq_tables[[i]])) {cat("\nTable of frequencies for", names(freq_tables)[i], ":\n")print(freq_tables[[i]]) }}
Table of frequencies for Gender_TEXT :
Var1 Freq Percent
1 Man 73 49.32
2 Woman 69 46.62
3 Nonbinary person 4 2.70
4 An identity not listed 2 1.35
Table of frequencies for Race_Ethnicity_TEXT :
Var1
1 Black or African American
2 Black or African American,Hispanic or Latina/o/x/e
3 Black or African American,White
4 East Asian
5 East Asian,Middle Eastern or North African,White
6 East Asian,White
7 Hispanic or Latina/o/x/e
8 Hispanic or Latina/o/x/e,Indigenous American, American Indian, or Alaska Native,White
9 Hispanic or Latina/o/x/e,White
10 Indigenous American, American Indian, or Alaska Native
11 Indigenous American, American Indian, or Alaska Native,White
12 Middle Eastern or North African
13 Middle Eastern or North African,White
14 Other
15 White
16 White,Other
Freq Percent
1 47 31.76
2 2 1.35
3 1 0.68
4 1 0.68
5 1 0.68
6 2 1.35
7 7 4.73
8 2 1.35
9 3 2.03
10 1 0.68
11 1 0.68
12 1 0.68
13 1 0.68
14 2 1.35
15 74 50.00
16 2 1.35
Table of frequencies for Political_overall_TEXT :
Var1 Freq Percent
1 Very liberal 18 12.16
2 Liberal 36 24.32
3 Somewhat liberal 10 6.76
4 Moderate 38 25.68
5 Somewhat conservative 18 12.16
6 Conservative 19 12.84
7 Very conservative 9 6.08
Table of frequencies for political_group :
Var1 Freq Percent
1 Liberal 64 43.24
2 Moderate 38 25.68
3 Conservative 46 31.08
Table of frequencies for White :
Var1 Freq Percent
1 White 87 58.78
2 Non-White 61 41.22
Table of frequencies for URM :
Var1 Freq Percent
1 Non-URM 98 66.22
2 URM 50 33.78
Demographic Plot
Code
# List of demographic columns to plotdemographic_columns <-c("Gender_TEXT", "Political_overall_TEXT", "political_group", "White", "URM")# Function to create percent plotcreate_percent_plot <-function(data, column) {# Calculate the frequency and percentage for each category freq_table <- data %>%group_by(across(all_of(column))) %>% dplyr::summarise(Freq =n()) %>%mutate(Percent = Freq /sum(Freq) *100)# Create the plot p <-ggplot(freq_table, aes_string(x = column, y ="Percent", fill = column)) +geom_bar(stat ="identity", position ="dodge") +scale_y_continuous(labels = scales::percent_format(scale =1)) +labs(x = column, y ="Percentage", title =paste("Distribution of", column)) +theme_minimal() +theme(axis.text.x =element_text(angle =45, hjust =1))return(p)}# Loop through demographic columns and plotplots <-lapply(demographic_columns, function(col) create_percent_plot(demo_data, col))# Display the plotsprint(plots)
[[1]]
[[2]]
[[3]]
[[4]]
[[5]]
Relationship Info
Relationship Type
Code
# Combine the columns close1_code, close2_code, and close3_code into one vectorall_relationships <-c(data$close1_code, data$close2_code, data$close3_code)# Count the occurrences of each unique relationship typerelationship_counts <-table(all_relationships)# Sort the counts in descending ordersorted_counts <-sort(relationship_counts, decreasing =TRUE)# Print the resultprint(sorted_counts)
# Remove any instances of "n/a"all_relationships <- all_relationships[all_relationships !="n/a"]
Relationship Closeness
Should police officer initiate interaction?
Main plot
Code
# Calculate proportionsdata_long_proportion <- data_long %>%group_by(relationship, interaction) %>% dplyr::summarise(count =n()) %>%mutate(proportion = count /sum(count))# Create the proportion plot with percentage y-axisInteraction_plot <-ggplot(data_long_proportion, aes(x=relationship, y=proportion, fill=factor(interaction))) +geom_bar(stat="identity", position="dodge") +scale_y_continuous(labels =percent_format()) +# Format y-axis as percentagescale_fill_manual(values =c("0"="#FF6F61", "1"="#4EC8BE"), # Customize the colors if desiredlabels =c("0"="No", "1"="Yes")) +# Change the legend labelsguides(fill =guide_legend(title =NULL)) +# Remove the legend titlelabs(x="Relationship", y="Percentage", title ="Should police officer initiate interaction?") +theme_minimal()# Print the plotprint(Interaction_plot)
Statistical testing
Code
contingency_table <-table(data_long$relationship, data_long$interaction)# Print the contingency table to see the countsprint(contingency_table)
0 1
close other 222 222
stranger 214 230
Code
# Perform the chi-square testchisq.test(contingency_table)
Pearson's Chi-squared test with Yates' continuity correction
data: contingency_table
X-squared = 0.22079, df = 1, p-value = 0.6384
Code
stranger_data <- data_long %>%filter(relationship =="stranger")contingency_table <-table(stranger_data$relationship, stranger_data$interaction)# Print the contingency table to see the countsprint(contingency_table)
0 1
stranger 214 230
Code
# Perform the chi-square testchisq.test(contingency_table)
Chi-squared test for given probabilities
data: contingency_table
X-squared = 0.57658, df = 1, p-value = 0.4477
Code
# Calculate the count for each relationship and interactiondata_long %>%group_by(relationship) %>% dplyr::summarise(count =n()) %>%ungroup()
# A tibble: 2 × 2
relationship count
<chr> <int>
1 close other 444
2 stranger 444
# A tibble: 12 × 3
relationship scenario count
<chr> <chr> <int>
1 close other brights 78
2 close other jay 72
3 close other jury 71
4 close other loiter 78
5 close other music 74
6 close other noise 71
7 stranger brights 70
8 stranger jay 76
9 stranger jury 77
10 stranger loiter 70
11 stranger music 74
12 stranger noise 77
Plot for each scenario
Code
# Calculate proportionsdata_long_proportion <- data_long %>%group_by(relationship, scenario, interaction) %>% dplyr::summarise(count =n()) %>%mutate(proportion = count /sum(count))# Create the proportion plot with percentage y-axisInteraction_plot_facet <-ggplot(data_long_proportion, aes(x=relationship, y=proportion, fill=factor(interaction))) +geom_bar(stat="identity", position="dodge") +scale_y_continuous(labels =percent_format()) +# Format y-axis as percentagescale_fill_manual(values =c("0"="#FF6F61", "1"="#4EC8BE"), # Customize the colors if desiredlabels =c("0"="No", "1"="Yes")) +# Change the legend labelsguides(fill =guide_legend(title =NULL)) +# Remove the legend titlelabs(x="Relationship", y="Percentage", title ="Should police officer initiate interaction?") +theme_minimal() +facet_wrap("scenario")print(Interaction_plot_facet)
Pearson's Chi-squared test with Yates' continuity correction
data: contingency_table_noise
X-squared = 0.0035298, df = 1, p-value = 0.9526
Would you prefer to confront the person yourself, or have a police officer confront them?
Main plot
Code
# Calculate proportionsdata_long_proportion <- data_long %>%group_by(relationship, confront) %>% dplyr::summarise(count =n()) %>%mutate(proportion = count /sum(count))# Create the proportion plot with percentage y-axisconfront_plot <-ggplot(data_long_proportion, aes(x=relationship, y=proportion, fill=factor(confront))) +geom_bar(stat="identity", position="dodge") +scale_y_continuous(labels =percent_format()) +# Format y-axis as percentagescale_fill_manual(values =c("1"="#8FCB9B", "2"="#B39DDB"), # Customize the colors if desiredlabels =c("1"="Confront them myself", "2"="Have a police officer confront them")) +# Change the legend labelsguides(fill =guide_legend(title =NULL)) +# Remove the legend titlelabs(x="Relationship", y="Percentage", title ="Would you prefer to confront the person yourself, or have a police officer confront them?") +theme_minimal()# Print the plotprint(confront_plot)
Statistical testing
Code
contingency_table <-table(data_long$relationship, data_long$confront)# Print the contingency table to see the countsprint(contingency_table)
1 2
close other 265 179
stranger 254 190
Code
# Perform the chi-square testchisq.test(contingency_table)
Pearson's Chi-squared test with Yates' continuity correction
data: contingency_table
X-squared = 0.46368, df = 1, p-value = 0.4959
Plot for each scenario
Code
# Calculate proportionsdata_long_proportion <- data_long %>%group_by(relationship, scenario, confront) %>% dplyr::summarise(count =n()) %>%mutate(proportion = count /sum(count))# Create the proportion plot with percentage y-axisconfront_facet_plot <-ggplot(data_long_proportion, aes(x=relationship, y=proportion, fill=factor(confront))) +geom_bar(stat="identity", position="dodge") +scale_y_continuous(labels =percent_format()) +# Format y-axis as percentagescale_fill_manual(values =c("1"="#8FCB9B", "2"="#B39DDB"), # Customize the colors if desiredlabels =c("1"="Confront them myself", "2"="Have a police officer confront them")) +# Change the legend labelsguides(fill =guide_legend(title =NULL)) +# Remove the legend titlelabs(x="Relationship", y="Percentage", title ="Would you prefer to confront the person yourself, or have a police officer confront them?") +theme_minimal() +facet_wrap("scenario")# Print the plotprint(confront_facet_plot)
Statistical testing
Code
contingency_table_jay <-table(jay_data$relationship, jay_data$confront)contingency_table_brights <-table(brights_data$relationship, brights_data$confront)contingency_table_jury <-table(jury_data$relationship, jury_data$confront)contingency_table_loiter <-table(loiter_data$relationship, loiter_data$confront)contingency_table_music <-table(music_data$relationship, music_data$confront)contingency_table_noise <-table(noise_data$relationship, noise_data$confront)# Print the contingency table to see the countsprint(contingency_table_jay)
1 2
close other 37 35
stranger 40 36
Code
print(contingency_table_brights)
1 2
close other 44 34
stranger 40 30
Code
print(contingency_table_jury)
1 2
close other 45 26
stranger 40 37
Code
print(contingency_table_loiter)
1 2
close other 52 26
stranger 42 28
Code
print(contingency_table_music)
1 2
close other 53 21
stranger 51 23
Code
print(contingency_table_noise)
1 2
close other 34 37
stranger 41 36
Code
# Perform the chi-square testchisq.test(contingency_table_jay)
Pearson's Chi-squared test with Yates' continuity correction
data: contingency_table_jay
X-squared = 0, df = 1, p-value = 1
Code
chisq.test(contingency_table_brights)
Pearson's Chi-squared test with Yates' continuity correction
data: contingency_table_brights
X-squared = 9.77e-31, df = 1, p-value = 1
Code
chisq.test(contingency_table_jury)
Pearson's Chi-squared test with Yates' continuity correction
data: contingency_table_jury
X-squared = 1.5348, df = 1, p-value = 0.2154
Code
chisq.test(contingency_table_loiter)
Pearson's Chi-squared test with Yates' continuity correction
data: contingency_table_loiter
X-squared = 0.4491, df = 1, p-value = 0.5028
Code
chisq.test(contingency_table_music)
Pearson's Chi-squared test with Yates' continuity correction
data: contingency_table_music
X-squared = 0.032343, df = 1, p-value = 0.8573
Code
chisq.test(contingency_table_noise)
Pearson's Chi-squared test with Yates' continuity correction
data: contingency_table_noise
X-squared = 0.23715, df = 1, p-value = 0.6263
Did this person break the rule?
Main plot
Code
# Calculate proportionsdata_long_proportion <- data_long %>%group_by(relationship, didBreak) %>% dplyr::summarise(count =n()) %>%mutate(proportion = count /sum(count))# Create the proportion plot with percentage y-axisdidBreak_plot <-ggplot(data_long_proportion, aes(x=relationship, y=proportion, fill=factor(didBreak))) +geom_bar(stat="identity", position="dodge") +scale_y_continuous(labels =percent_format()) +# Format y-axis as percentagescale_fill_manual(values =c("0"="#FF6F61", "1"="#4EC8BE"), # Customize the colors if desiredlabels =c("0"="No", "1"="Yes")) +# Change the legend labelsguides(fill =guide_legend(title =NULL)) +# Remove the legend titlelabs(x="Relationship", y="Percentage", title ="Did this person break the rule?") +theme_minimal()# Print the plotprint(didBreak_plot)
Statistical testing
Code
contingency_table <-table(data_long$relationship, data_long$didBreak)# Print the contingency table to see the countsprint(contingency_table)
0 1
close other 53 391
stranger 47 397
Code
# Perform the chi-square testchisq.test(contingency_table)
Pearson's Chi-squared test with Yates' continuity correction
data: contingency_table
X-squared = 0.28173, df = 1, p-value = 0.5956
Plot for each scenario
Code
# Calculate proportionsdata_long_proportion <- data_long %>%group_by(relationship, scenario, didBreak) %>% dplyr::summarise(count =n()) %>%mutate(proportion = count /sum(count))# Create the proportion plot with percentage y-axisdidBreak_facet_plot <-ggplot(data_long_proportion, aes(x=relationship, y=proportion, fill=factor(didBreak))) +geom_bar(stat="identity", position="dodge") +scale_y_continuous(labels =percent_format()) +# Format y-axis as percentagescale_fill_manual(values =c("0"="#FF6F61", "1"="#4EC8BE"), # Customize the colors if desiredlabels =c("0"="No", "1"="Yes")) +# Change the legend labelsguides(fill =guide_legend(title =NULL)) +# Remove the legend titlelabs(x="Relationship", y="Percentage", title ="Did this person break the rule?") +theme_minimal() +facet_wrap("scenario")# Print the plotprint(didBreak_facet_plot)
Statistical testing
Code
contingency_table_jay <-table(jay_data$relationship, jay_data$didBreak)contingency_table_brights <-table(brights_data$relationship, brights_data$didBreak)contingency_table_jury <-table(jury_data$relationship, jury_data$didBreak)contingency_table_loiter <-table(loiter_data$relationship, loiter_data$didBreak)contingency_table_music <-table(music_data$relationship, music_data$didBreak)contingency_table_noise <-table(noise_data$relationship, noise_data$didBreak)# Print the contingency table to see the countsprint(contingency_table_jay)
0 1
close other 8 64
stranger 13 63
Code
print(contingency_table_brights)
0 1
close other 11 67
stranger 9 61
Code
print(contingency_table_jury)
0 1
close other 8 63
stranger 9 68
Code
print(contingency_table_loiter)
0 1
close other 17 61
stranger 9 61
Code
print(contingency_table_music)
0 1
close other 7 67
stranger 3 71
Code
print(contingency_table_noise)
0 1
close other 2 69
stranger 4 73
Code
# Perform the chi-square testchisq.test(contingency_table_jay)
Pearson's Chi-squared test with Yates' continuity correction
data: contingency_table_jay
X-squared = 0.65427, df = 1, p-value = 0.4186
Code
chisq.test(contingency_table_brights)
Pearson's Chi-squared test with Yates' continuity correction
data: contingency_table_brights
X-squared = 1.0961e-29, df = 1, p-value = 1
Code
chisq.test(contingency_table_jury)
Pearson's Chi-squared test with Yates' continuity correction
data: contingency_table_jury
X-squared = 7.4368e-31, df = 1, p-value = 1
Code
chisq.test(contingency_table_loiter)
Pearson's Chi-squared test with Yates' continuity correction
data: contingency_table_loiter
X-squared = 1.4647, df = 1, p-value = 0.2262
Code
chisq.test(contingency_table_music)
Pearson's Chi-squared test with Yates' continuity correction
data: contingency_table_music
X-squared = 0.96522, df = 1, p-value = 0.3259
Code
chisq.test(contingency_table_noise)
Pearson's Chi-squared test with Yates' continuity correction
data: contingency_table_noise
X-squared = 0.099644, df = 1, p-value = 0.7523
Does punishing people who break the rule help maintain order?
Main plot
Code
# Calculate proportionsdata_long_proportion <- data_long %>%group_by(relationship, order) %>% dplyr::summarise(count =n()) %>%mutate(proportion = count /sum(count))# Create the proportion plot with percentage y-axisorder_plot <-ggplot(data_long_proportion, aes(x=relationship, y=proportion, fill=factor(order))) +geom_bar(stat="identity", position="dodge") +scale_y_continuous(labels =percent_format()) +# Format y-axis as percentagescale_fill_manual(values =c("0"="#FF6F61", "1"="#4EC8BE"), # Customize the colors if desiredlabels =c("0"="No", "1"="Yes")) +# Change the legend labelsguides(fill =guide_legend(title =NULL)) +# Remove the legend titlelabs(x="Relationship", y="Percentage", title ="Does punishing people who break the rule help maintain order?") +theme_minimal()# Print the plotprint(order_plot)
Statistical testing
Code
contingency_table <-table(data_long$relationship, data_long$order)# Print the contingency table to see the countsprint(contingency_table)
0 1
close other 197 247
stranger 206 238
Code
# Perform the chi-square testchisq.test(contingency_table)
Pearson's Chi-squared test with Yates' continuity correction
data: contingency_table
X-squared = 0.29077, df = 1, p-value = 0.5897
Plot for each scenario
jaywalking significant
Code
# Calculate proportionsdata_long_proportion <- data_long %>%group_by(relationship, scenario, order) %>% dplyr::summarise(count =n()) %>%mutate(proportion = count /sum(count))# Create the proportion plot with percentage y-axisorder_facet_plot <-ggplot(data_long_proportion, aes(x=relationship, y=proportion, fill=factor(order))) +geom_bar(stat="identity", position="dodge") +scale_y_continuous(labels =percent_format()) +# Format y-axis as percentagescale_fill_manual(values =c("0"="#FF6F61", "1"="#4EC8BE"), # Customize the colors if desiredlabels =c("0"="No", "1"="Yes")) +# Change the legend labelsguides(fill =guide_legend(title =NULL)) +# Remove the legend titlelabs(x="Relationship", y="Percentage", title ="Does punishing people who break the rule help maintain order?") +theme_minimal() +facet_wrap("scenario")print(order_facet_plot)
Statistical testing
Code
contingency_table_jay <-table(jay_data$relationship, jay_data$order)contingency_table_brights <-table(brights_data$relationship, brights_data$order)contingency_table_jury <-table(jury_data$relationship, jury_data$order)contingency_table_loiter <-table(loiter_data$relationship, loiter_data$order)contingency_table_music <-table(music_data$relationship, music_data$order)contingency_table_noise <-table(noise_data$relationship, noise_data$order)# Print the contingency table to see the countsprint(contingency_table_jay)
0 1
close other 25 47
stranger 46 30
Code
print(contingency_table_brights)
0 1
close other 30 48
stranger 23 47
Code
print(contingency_table_jury)
0 1
close other 40 31
stranger 40 37
Code
print(contingency_table_loiter)
0 1
close other 44 34
stranger 42 28
Code
print(contingency_table_music)
0 1
close other 48 26
stranger 43 31
Code
print(contingency_table_noise)
0 1
close other 10 61
stranger 12 65
Code
# Perform the chi-square testchisq.test(contingency_table_jay)
Pearson's Chi-squared test with Yates' continuity correction
data: contingency_table_jay
X-squared = 8.8568, df = 1, p-value = 0.00292
Code
chisq.test(contingency_table_brights)
Pearson's Chi-squared test with Yates' continuity correction
data: contingency_table_brights
X-squared = 0.28976, df = 1, p-value = 0.5904
Code
chisq.test(contingency_table_jury)
Pearson's Chi-squared test with Yates' continuity correction
data: contingency_table_jury
X-squared = 0.13713, df = 1, p-value = 0.7112
Code
chisq.test(contingency_table_loiter)
Pearson's Chi-squared test with Yates' continuity correction
data: contingency_table_loiter
X-squared = 0.075666, df = 1, p-value = 0.7833
Code
chisq.test(contingency_table_music)
Pearson's Chi-squared test with Yates' continuity correction
data: contingency_table_music
X-squared = 0.45653, df = 1, p-value = 0.4993
Code
chisq.test(contingency_table_noise)
Pearson's Chi-squared test with Yates' continuity correction
data: contingency_table_noise
X-squared = 0.00062503, df = 1, p-value = 0.9801
Would you want to anonymously report this person?
Main plot + distribution
Code
anonReport_plot <-ggplot(data_long, aes(x = relationship, y = anonReport)) +geom_point(stat ="summary", fun ="mean", size =4, position =position_dodge(width =0.25)) +geom_violin(aes(fill = anonReport), alpha =0.3, position =position_dodge(width =0.25)) +# plotting distributionsstat_summary(fun.data ="mean_cl_normal", geom ="errorbar", position =position_dodge(width =0.25), width =0.2, size =1.5) +labs(x ="Relationship", y ="Likelihood they would report", title ="Would you want to anonymously report this person?") +theme_minimal(base_size =15) +# Use a minimal themetheme(plot.title =element_text(hjust =0.5, size =25),axis.text.x =element_text(face ="plain", size =25, color ="black"),axis.text.y =element_text(face ="plain", size =25, color ="black"),axis.title.y =element_text(face ="plain", size =30, color ="black"), axis.title.x =element_text(face ="plain", size =30, color ="black"),panel.grid.major =element_line(color ="gray"), # Set major grid lines to graypanel.grid.minor =element_blank(), # Hide minor grid linespanel.background =element_rect(fill ="white", color ="white"),panel.border =element_rect(color ="black", fill =NA, size =1) ) +coord_cartesian(ylim =c(0, 100)) +scale_y_continuous(breaks =c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(anonReport_plot)
Main plot + distribution for each scenario
Code
anonReport_plot <-ggplot(data_long, aes(x = relationship, y = anonReport)) +geom_point(stat ="summary", fun ="mean", size =4, position =position_dodge(width =0.25)) +geom_violin(aes(fill = anonReport), alpha =0.3, position =position_dodge(width =0.25)) +# plotting distributionsstat_summary(fun.data ="mean_cl_normal", geom ="errorbar", position =position_dodge(width =0.25), width =0.2, size =1.5) +labs(x ="Relationship", y ="Likelihood they would report", title ="Would you want to anonymously report this person?") +theme_minimal(base_size =15) +# Use a minimal themetheme(plot.title =element_text(hjust =0.5, size =25),axis.text.x =element_text(face ="plain", size =17, color ="black"),axis.text.y =element_text(face ="plain", size =25, color ="black"),axis.title.y =element_text(face ="plain", size =30, color ="black"), axis.title.x =element_text(face ="plain", size =30, color ="black"),panel.grid.major =element_line(color ="gray"), # Set major grid lines to graypanel.grid.minor =element_blank(), # Hide minor grid linespanel.background =element_rect(fill ="white", color ="white"),panel.border =element_rect(color ="black", fill =NA, size =1) ) +facet_wrap("scenario") +coord_cartesian(ylim =c(0, 100)) +scale_y_continuous(breaks =c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(anonReport_plot)
Would you want to publicly report this person?
Main plot + distribution
Code
publicReport_plot <-ggplot(data_long, aes(x = relationship, y = publicReport)) +geom_point(stat ="summary", fun ="mean", size =4, position =position_dodge(width =0.25)) +geom_violin(aes(fill = publicReport), alpha =0.3, position =position_dodge(width =0.25)) +# plotting distributionsstat_summary(fun.data ="mean_cl_normal", geom ="errorbar", position =position_dodge(width =0.25), width =0.2, size =1.5) +labs(x ="Relationship", y ="Likelihood they would report", title ="Would you want to publicly report this person?") +theme_minimal(base_size =15) +# Use a minimal themetheme(plot.title =element_text(hjust =0.5, size =25),axis.text.x =element_text(face ="plain", size =25, color ="black"),axis.text.y =element_text(face ="plain", size =25, color ="black"),axis.title.y =element_text(face ="plain", size =30, color ="black"), axis.title.x =element_text(face ="plain", size =30, color ="black"),panel.grid.major =element_line(color ="gray"), # Set major grid lines to graypanel.grid.minor =element_blank(), # Hide minor grid linespanel.background =element_rect(fill ="white", color ="white"),panel.border =element_rect(color ="black", fill =NA, size =1) ) +coord_cartesian(ylim =c(0, 100)) +scale_y_continuous(breaks =c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(publicReport_plot)
Main plot + distribution for each scenario
Code
publicReport_plot <-ggplot(data_long, aes(x = relationship, y = publicReport)) +geom_point(stat ="summary", fun ="mean", size =4, position =position_dodge(width =0.25)) +geom_violin(aes(fill = publicReport), alpha =0.3, position =position_dodge(width =0.25)) +# plotting distributionsstat_summary(fun.data ="mean_cl_normal", geom ="errorbar", position =position_dodge(width =0.25), width =0.2, size =1.5) +labs(x ="Relationship", y ="Likelihood they would report", title ="Would you want to publicly report this person?") +theme_minimal(base_size =15) +# Use a minimal themetheme(plot.title =element_text(hjust =0.5, size =25),axis.text.x =element_text(face ="plain", size =17, color ="black"),axis.text.y =element_text(face ="plain", size =25, color ="black"),axis.title.y =element_text(face ="plain", size =30, color ="black"), axis.title.x =element_text(face ="plain", size =30, color ="black"),panel.grid.major =element_line(color ="gray"), # Set major grid lines to graypanel.grid.minor =element_blank(), # Hide minor grid linespanel.background =element_rect(fill ="white", color ="white"),panel.border =element_rect(color ="black", fill =NA, size =1) ) +facet_wrap("scenario") +coord_cartesian(ylim =c(0, 100)) +scale_y_continuous(breaks =c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(publicReport_plot)
Do you want this person to know that you reported him/her?
Main plot + distribution
Code
knowReport_plot <-ggplot(data_long, aes(x = relationship, y = knowReport)) +geom_point(stat ="summary", fun ="mean", size =4, position =position_dodge(width =0.25)) +geom_violin(aes(fill = knowReport), alpha =0.3, position =position_dodge(width =0.25)) +# plotting distributionsstat_summary(fun.data ="mean_cl_normal", geom ="errorbar", position =position_dodge(width =0.25), width =0.2, size =1.5) +labs(x ="Relationship", y ="Likelihood they want to be known it was them", title ="Do you want this person to know that you reported him/her?") +theme_minimal(base_size =15) +# Use a minimal themetheme(plot.title =element_text(hjust =0.5, size =20),axis.text.x =element_text(face ="plain", size =25, color ="black"),axis.text.y =element_text(face ="plain", size =25, color ="black"),axis.title.y =element_text(face ="plain", size =15, color ="black"), axis.title.x =element_text(face ="plain", size =30, color ="black"),panel.grid.major =element_line(color ="gray"), # Set major grid lines to graypanel.grid.minor =element_blank(), # Hide minor grid linespanel.background =element_rect(fill ="white", color ="white"),panel.border =element_rect(color ="black", fill =NA, size =1) ) +coord_cartesian(ylim =c(0, 100)) +scale_y_continuous(breaks =c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(knowReport_plot)
Main plot + distribution for each scenario
Code
knowReport_plot <-ggplot(data_long, aes(x = relationship, y = knowReport)) +geom_point(stat ="summary", fun ="mean", size =4, position =position_dodge(width =0.25)) +geom_violin(aes(fill = knowReport), alpha =0.3, position =position_dodge(width =0.25)) +# plotting distributionsstat_summary(fun.data ="mean_cl_normal", geom ="errorbar", position =position_dodge(width =0.25), width =0.2, size =1.5) +labs(x ="Relationship", y ="Likelihood they want to be known it was them", title ="Do you want this person to know that you reported him/her?") +theme_minimal(base_size =15) +# Use a minimal themetheme(plot.title =element_text(hjust =0.5, size =20),axis.text.x =element_text(face ="plain", size =17, color ="black"),axis.text.y =element_text(face ="plain", size =25, color ="black"),axis.title.y =element_text(face ="plain", size =15, color ="black"), axis.title.x =element_text(face ="plain", size =30, color ="black"),panel.grid.major =element_line(color ="gray"), # Set major grid lines to graypanel.grid.minor =element_blank(), # Hide minor grid linespanel.background =element_rect(fill ="white", color ="white"),panel.border =element_rect(color ="black", fill =NA, size =1) ) +facet_wrap("scenario") +coord_cartesian(ylim =c(0, 100)) +scale_y_continuous(breaks =c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(knowReport_plot)
How punishable is the act?
Main plot + distribution
Code
punish_plot <-ggplot(data_long, aes(x = relationship, y = punish)) +geom_point(stat ="summary", fun ="mean", size =4, position =position_dodge(width =0.25)) +geom_violin(aes(fill = punish), alpha =0.3, position =position_dodge(width =0.25)) +# plotting distributionsstat_summary(fun.data ="mean_cl_normal", geom ="errorbar", position =position_dodge(width =0.25), width =0.2, size =1.5) +labs(x ="Relationship", y ="How punishable they would report", title ="How punishable is the act?") +theme_minimal(base_size =15) +# Use a minimal themetheme(plot.title =element_text(hjust =0.5, size =35),axis.text.x =element_text(face ="plain", size =25, color ="black"),axis.text.y =element_text(face ="plain", size =25, color ="black"),axis.title.y =element_text(face ="plain", size =30, color ="black"), axis.title.x =element_text(face ="plain", size =30, color ="black"),panel.grid.major =element_line(color ="gray"), # Set major grid lines to graypanel.grid.minor =element_blank(), # Hide minor grid linespanel.background =element_rect(fill ="white", color ="white"),panel.border =element_rect(color ="black", fill =NA, size =1) ) +coord_cartesian(ylim =c(0, 100)) +scale_y_continuous(breaks =c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(punish_plot)
Main plot + distribution for each scenario
Code
punish_plot <-ggplot(data_long, aes(x = relationship, y = punish)) +geom_point(stat ="summary", fun ="mean", size =4, position =position_dodge(width =0.25)) +geom_violin(aes(fill = punish), alpha =0.3, position =position_dodge(width =0.25)) +# plotting distributionsstat_summary(fun.data ="mean_cl_normal", geom ="errorbar", position =position_dodge(width =0.25), width =0.2, size =1.5) +labs(x ="Relationship", y ="How punishable they would report", title ="How punishable is the act?") +theme_minimal(base_size =15) +# Use a minimal themetheme(plot.title =element_text(hjust =0.5, size =35),axis.text.x =element_text(face ="plain", size =17, color ="black"),axis.text.y =element_text(face ="plain", size =25, color ="black"),axis.title.y =element_text(face ="plain", size =30, color ="black"), axis.title.x =element_text(face ="plain", size =30, color ="black"),panel.grid.major =element_line(color ="gray"), # Set major grid lines to graypanel.grid.minor =element_blank(), # Hide minor grid linespanel.background =element_rect(fill ="white", color ="white"),panel.border =element_rect(color ="black", fill =NA, size =1) ) +facet_wrap("scenario") +coord_cartesian(ylim =c(0, 100)) +scale_y_continuous(breaks =c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(punish_plot)
How morally bad is the act?
Main plot + distribution
Code
moral_plot <-ggplot(data_long, aes(x = relationship, y = moral)) +geom_point(stat ="summary", fun ="mean", size =4, position =position_dodge(width =0.25)) +geom_violin(aes(fill = moral), alpha =0.3, position =position_dodge(width =0.25)) +# plotting distributionsstat_summary(fun.data ="mean_cl_normal", geom ="errorbar", position =position_dodge(width =0.25), width =0.2, size =1.5) +labs(x ="Relationship", y ="How morally bad they would report", title ="How morally bad is the act?") +theme_minimal(base_size =15) +# Use a minimal themetheme(plot.title =element_text(hjust =0.5, size =35),axis.text.x =element_text(face ="plain", size =25, color ="black"),axis.text.y =element_text(face ="plain", size =25, color ="black"),axis.title.y =element_text(face ="plain", size =30, color ="black"), axis.title.x =element_text(face ="plain", size =30, color ="black"),panel.grid.major =element_line(color ="gray"), # Set major grid lines to graypanel.grid.minor =element_blank(), # Hide minor grid linespanel.background =element_rect(fill ="white", color ="white"),panel.border =element_rect(color ="black", fill =NA, size =1) ) +coord_cartesian(ylim =c(0, 100)) +scale_y_continuous(breaks =c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(moral_plot)
Main plot + distribution for each scenario
Code
moral_plot <-ggplot(data_long, aes(x = relationship, y = moral)) +geom_point(stat ="summary", fun ="mean", size =4, position =position_dodge(width =0.25)) +geom_violin(aes(fill = moral), alpha =0.3, position =position_dodge(width =0.25)) +# plotting distributionsstat_summary(fun.data ="mean_cl_normal", geom ="errorbar", position =position_dodge(width =0.25), width =0.2, size =1.5) +labs(x ="Relationship", y ="How morally bad they would report", title ="How morally bad is the act?") +theme_minimal(base_size =15) +# Use a minimal themetheme(plot.title =element_text(hjust =0.5, size =35),axis.text.x =element_text(face ="plain", size =17, color ="black"),axis.text.y =element_text(face ="plain", size =25, color ="black"),axis.title.y =element_text(face ="plain", size =30, color ="black"), axis.title.x =element_text(face ="plain", size =30, color ="black"),panel.grid.major =element_line(color ="gray"), # Set major grid lines to graypanel.grid.minor =element_blank(), # Hide minor grid linespanel.background =element_rect(fill ="white", color ="white"),panel.border =element_rect(color ="black", fill =NA, size =1) ) +facet_wrap("scenario") +coord_cartesian(ylim =c(0, 100)) +scale_y_continuous(breaks =c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(moral_plot)
How justified is it for the legal system to be involved when a person violate a speficit phantom rule?
Main plot + distribution
Code
justified_plot <-ggplot(data_long, aes(x = relationship, y = justified)) +geom_point(stat ="summary", fun ="mean", size =4, position =position_dodge(width =0.25)) +geom_violin(aes(fill = justified), alpha =0.3, position =position_dodge(width =0.25)) +# plotting distributionsstat_summary(fun.data ="mean_cl_normal", geom ="errorbar", position =position_dodge(width =0.25), width =0.2, size =1.5) +labs(x ="Relationship", y ="Justified level", title ="How justified is it for the legal system to be involved when a person violate the rule?") +theme_minimal(base_size =15) +# Use a minimal themetheme(plot.title =element_text(hjust =0.5, size =15),axis.text.x =element_text(face ="plain", size =25, color ="black"),axis.text.y =element_text(face ="plain", size =25, color ="black"),axis.title.y =element_text(face ="plain", size =30, color ="black"), axis.title.x =element_text(face ="plain", size =30, color ="black"),panel.grid.major =element_line(color ="gray"), # Set major grid lines to graypanel.grid.minor =element_blank(), # Hide minor grid linespanel.background =element_rect(fill ="white", color ="white"),panel.border =element_rect(color ="black", fill =NA, size =1) ) +coord_cartesian(ylim =c(0, 100)) +scale_y_continuous(breaks =c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(justified_plot)
Main plot + distribution for each scenario
Code
justified_plot <-ggplot(data_long, aes(x = relationship, y = justified)) +geom_point(stat ="summary", fun ="mean", size =4, position =position_dodge(width =0.25)) +geom_violin(aes(fill = justified), alpha =0.3, position =position_dodge(width =0.25)) +# plotting distributionsstat_summary(fun.data ="mean_cl_normal", geom ="errorbar", position =position_dodge(width =0.25), width =0.2, size =1.5) +labs(x ="Relationship", y ="Justified level", title ="How justified is it for the legal system to be involved when a person violate the rule?") +theme_minimal(base_size =15) +# Use a minimal themetheme(plot.title =element_text(hjust =0.5, size =15),axis.text.x =element_text(face ="plain", size =17, color ="black"),axis.text.y =element_text(face ="plain", size =25, color ="black"),axis.title.y =element_text(face ="plain", size =30, color ="black"), axis.title.x =element_text(face ="plain", size =30, color ="black"),panel.grid.major =element_line(color ="gray"), # Set major grid lines to graypanel.grid.minor =element_blank(), # Hide minor grid linespanel.background =element_rect(fill ="white", color ="white"),panel.border =element_rect(color ="black", fill =NA, size =1) ) +facet_wrap("scenario") +coord_cartesian(ylim =c(0, 100)) +scale_y_continuous(breaks =c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(justified_plot)
How legitimate is the law against the rule?
Main plot + distribution
Code
legit_plot <-ggplot(data_long, aes(x = relationship, y = legit)) +geom_point(stat ="summary", fun ="mean", size =4, position =position_dodge(width =0.25)) +geom_violin(aes(fill = legit), alpha =0.3, position =position_dodge(width =0.25)) +# plotting distributionsstat_summary(fun.data ="mean_cl_normal", geom ="errorbar", position =position_dodge(width =0.25), width =0.2, size =1.5) +labs(x ="Relationship", y ="Legitimate level", title ="How legitimate is the law against the rule?") +theme_minimal(base_size =15) +# Use a minimal themetheme(plot.title =element_text(hjust =0.5, size =30),axis.text.x =element_text(face ="plain", size =25, color ="black"),axis.text.y =element_text(face ="plain", size =25, color ="black"),axis.title.y =element_text(face ="plain", size =30, color ="black"), axis.title.x =element_text(face ="plain", size =30, color ="black"),panel.grid.major =element_line(color ="gray"), # Set major grid lines to graypanel.grid.minor =element_blank(), # Hide minor grid linespanel.background =element_rect(fill ="white", color ="white"),panel.border =element_rect(color ="black", fill =NA, size =1) ) +coord_cartesian(ylim =c(0, 100)) +scale_y_continuous(breaks =c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(legit_plot)
Main plot + distribution for each scenario
Code
legit_plot <-ggplot(data_long, aes(x = relationship, y = legit)) +geom_point(stat ="summary", fun ="mean", size =4, position =position_dodge(width =0.25)) +geom_violin(aes(fill = legit), alpha =0.3, position =position_dodge(width =0.25)) +# plotting distributionsstat_summary(fun.data ="mean_cl_normal", geom ="errorbar", position =position_dodge(width =0.25), width =0.2, size =1.5) +labs(x ="Relationship", y ="Legitimate level", title ="How legitimate is the law against the rule?") +theme_minimal(base_size =15) +# Use a minimal themetheme(plot.title =element_text(hjust =0.5, size =30),axis.text.x =element_text(face ="plain", size =17, color ="black"),axis.text.y =element_text(face ="plain", size =25, color ="black"),axis.title.y =element_text(face ="plain", size =30, color ="black"), axis.title.x =element_text(face ="plain", size =30, color ="black"),panel.grid.major =element_line(color ="gray"), # Set major grid lines to graypanel.grid.minor =element_blank(), # Hide minor grid linespanel.background =element_rect(fill ="white", color ="white"),panel.border =element_rect(color ="black", fill =NA, size =1) ) +facet_wrap("scenario") +coord_cartesian(ylim =c(0, 100)) +scale_y_continuous(breaks =c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(legit_plot)
How fair is the law against the violation of the phantom rule?
Main plot + distribution
Code
fair_plot <-ggplot(data_long, aes(x = relationship, y = fair)) +geom_point(stat ="summary", fun ="mean", size =4, position =position_dodge(width =0.25)) +geom_violin(aes(fill = fair), alpha =0.3, position =position_dodge(width =0.25)) +# plotting distributionsstat_summary(fun.data ="mean_cl_normal", geom ="errorbar", position =position_dodge(width =0.25), width =0.2, size =1.5) +labs(x ="Relationship", y ="Fair level", title ="How fair is the law on the phantom rule?") +theme_minimal(base_size =15) +# Use a minimal themetheme(plot.title =element_text(hjust =0.5, size =35),axis.text.x =element_text(face ="plain", size =25, color ="black"),axis.text.y =element_text(face ="plain", size =25, color ="black"),axis.title.y =element_text(face ="plain", size =30, color ="black"), axis.title.x =element_text(face ="plain", size =30, color ="black"),panel.grid.major =element_line(color ="gray"), # Set major grid lines to graypanel.grid.minor =element_blank(), # Hide minor grid linespanel.background =element_rect(fill ="white", color ="white"),panel.border =element_rect(color ="black", fill =NA, size =1) ) +coord_cartesian(ylim =c(0, 100)) +scale_y_continuous(breaks =c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(fair_plot)
Main plot + distribution for each scenario
Code
fair_plot <-ggplot(data_long, aes(x = relationship, y = fair)) +geom_point(stat ="summary", fun ="mean", size =4, position =position_dodge(width =0.25)) +geom_violin(aes(fill = fair), alpha =0.3, position =position_dodge(width =0.25)) +# plotting distributionsstat_summary(fun.data ="mean_cl_normal", geom ="errorbar", position =position_dodge(width =0.25), width =0.2, size =1.5) +labs(x ="Relationship", y ="Fair level", title ="How fair is the law on the phantom rule?") +theme_minimal(base_size =15) +# Use a minimal themetheme(plot.title =element_text(hjust =0.5, size =35),axis.text.x =element_text(face ="plain", size =17, color ="black"),axis.text.y =element_text(face ="plain", size =25, color ="black"),axis.title.y =element_text(face ="plain", size =30, color ="black"), axis.title.x =element_text(face ="plain", size =30, color ="black"),panel.grid.major =element_line(color ="gray"), # Set major grid lines to graypanel.grid.minor =element_blank(), # Hide minor grid linespanel.background =element_rect(fill ="white", color ="white"),panel.border =element_rect(color ="black", fill =NA, size =1) ) +facet_wrap("scenario") +coord_cartesian(ylim =c(0, 100)) +scale_y_continuous(breaks =c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(fair_plot)
How likely is it that this person will break rules in the future?
Main plot + distribution
Code
breakP_plot <-ggplot(data_long, aes(x = relationship, y = breakP)) +geom_point(stat ="summary", fun ="mean", size =4, position =position_dodge(width =0.25)) +geom_violin(aes(fill = breakP), alpha =0.3, position =position_dodge(width =0.25)) +# plotting distributionsstat_summary(fun.data ="mean_cl_normal", geom ="errorbar", position =position_dodge(width =0.25), width =0.2, size =1.5) +labs(x ="Relationship", y ="Likelihood to break rule", title ="How likely is it that this person will break rules in the future?") +theme_minimal(base_size =15) +# Use a minimal themetheme(plot.title =element_text(hjust =0.5, size =20),axis.text.x =element_text(face ="plain", size =25, color ="black"),axis.text.y =element_text(face ="plain", size =25, color ="black"),axis.title.y =element_text(face ="plain", size =30, color ="black"), axis.title.x =element_text(face ="plain", size =30, color ="black"),panel.grid.major =element_line(color ="gray"), # Set major grid lines to graypanel.grid.minor =element_blank(), # Hide minor grid linespanel.background =element_rect(fill ="white", color ="white"),panel.border =element_rect(color ="black", fill =NA, size =1) ) +coord_cartesian(ylim =c(0, 100)) +scale_y_continuous(breaks =c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(breakP_plot)
Main plot + distribution for each scenario
Code
breakP_plot <-ggplot(data_long, aes(x = relationship, y = breakP)) +geom_point(stat ="summary", fun ="mean", size =4, position =position_dodge(width =0.25)) +geom_violin(aes(fill = breakP), alpha =0.3, position =position_dodge(width =0.25)) +# plotting distributionsstat_summary(fun.data ="mean_cl_normal", geom ="errorbar", position =position_dodge(width =0.25), width =0.2, size =1.5) +labs(x ="Relationship", y ="Likelihood to break rule", title ="How likely is it that this person will break rules in the future?") +theme_minimal(base_size =15) +# Use a minimal themetheme(plot.title =element_text(hjust =0.5, size =20),axis.text.x =element_text(face ="plain", size =17, color ="black"),axis.text.y =element_text(face ="plain", size =25, color ="black"),axis.title.y =element_text(face ="plain", size =30, color ="black"), axis.title.x =element_text(face ="plain", size =30, color ="black"),panel.grid.major =element_line(color ="gray"), # Set major grid lines to graypanel.grid.minor =element_blank(), # Hide minor grid linespanel.background =element_rect(fill ="white", color ="white"),panel.border =element_rect(color ="black", fill =NA, size =1) ) +facet_wrap("scenario") +coord_cartesian(ylim =c(0, 100)) +scale_y_continuous(breaks =c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(breakP_plot)
How much do you feel the actions of this person were harmful to others?
Main plot + distribution
Code
harmP_plot <-ggplot(data_long, aes(x = relationship, y = harmP)) +geom_point(stat ="summary", fun ="mean", size =4, position =position_dodge(width =0.25)) +geom_violin(aes(fill = harmP), alpha =0.3, position =position_dodge(width =0.25)) +# plotting distributionsstat_summary(fun.data ="mean_cl_normal", geom ="errorbar", position =position_dodge(width =0.25), width =0.2, size =1.5) +labs(x ="Relationship", y ="Level of harmfulness", title ="How much do you feel the actions of this person were harmful to others?") +theme_minimal(base_size =15) +# Use a minimal themetheme(plot.title =element_text(hjust =0.5, size =20),axis.text.x =element_text(face ="plain", size =25, color ="black"),axis.text.y =element_text(face ="plain", size =25, color ="black"),axis.title.y =element_text(face ="plain", size =30, color ="black"), axis.title.x =element_text(face ="plain", size =30, color ="black"),panel.grid.major =element_line(color ="gray"), # Set major grid lines to graypanel.grid.minor =element_blank(), # Hide minor grid linespanel.background =element_rect(fill ="white", color ="white"),panel.border =element_rect(color ="black", fill =NA, size =1) ) +coord_cartesian(ylim =c(0, 100)) +scale_y_continuous(breaks =c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(harmP_plot)
Main plot + distribution for each scenario
Code
harmP_plot <-ggplot(data_long, aes(x = relationship, y = harmP)) +geom_point(stat ="summary", fun ="mean", size =4, position =position_dodge(width =0.25)) +geom_violin(aes(fill = harmP), alpha =0.3, position =position_dodge(width =0.25)) +# plotting distributionsstat_summary(fun.data ="mean_cl_normal", geom ="errorbar", position =position_dodge(width =0.25), width =0.2, size =1.5) +labs(x ="Relationship", y ="Level of harmfulness", title ="How much do you feel the actions of this person were harmful to others?") +theme_minimal(base_size =15) +# Use a minimal themetheme(plot.title =element_text(hjust =0.5, size =20),axis.text.x =element_text(face ="plain", size =17, color ="black"),axis.text.y =element_text(face ="plain", size =25, color ="black"),axis.title.y =element_text(face ="plain", size =30, color ="black"), axis.title.x =element_text(face ="plain", size =30, color ="black"),panel.grid.major =element_line(color ="gray"), # Set major grid lines to graypanel.grid.minor =element_blank(), # Hide minor grid linespanel.background =element_rect(fill ="white", color ="white"),panel.border =element_rect(color ="black", fill =NA, size =1) ) +facet_wrap("scenario") +coord_cartesian(ylim =c(0, 100)) +scale_y_continuous(breaks =c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(harmP_plot)
Should the legal system consider getting rid of the law prohibiting the phantom rule?
Main plot + distribution
Code
remove_plot <-ggplot(data_long, aes(x = relationship, y = remove)) +geom_point(stat ="summary", fun ="mean", size =4, position =position_dodge(width =0.25)) +geom_violin(aes(fill = remove), alpha =0.3, position =position_dodge(width =0.25)) +# plotting distributionsstat_summary(fun.data ="mean_cl_normal", geom ="errorbar", position =position_dodge(width =0.25), width =0.2, size =1.5) +labs(x ="Relationship", y ="How much they would agree or disagree with the statement", title ="The legal system should consider getting rid of the law prohibiting the phantom rule.") +theme_minimal(base_size =15) +# Use a minimal themetheme(plot.title =element_text(hjust =0.5, size =17),axis.text.x =element_text(face ="plain", size =25, color ="black"),axis.text.y =element_text(face ="plain", size =25, color ="black"),axis.title.y =element_text(face ="plain", size =15, color ="black"), axis.title.x =element_text(face ="plain", size =30, color ="black"),panel.grid.major =element_line(color ="gray"), # Set major grid lines to graypanel.grid.minor =element_blank(), # Hide minor grid linespanel.background =element_rect(fill ="white", color ="white"),panel.border =element_rect(color ="black", fill =NA, size =1) ) +coord_cartesian(ylim =c(-100, 100)) +scale_y_continuous(breaks =c(-100, -50, 0, 50, 100)) #-100-100: -100, -50, 0, 50, 100print(remove_plot)
Main plot + distribution for each scenario
Code
remove_plot <-ggplot(data_long, aes(x = relationship, y = remove)) +geom_point(stat ="summary", fun ="mean", size =4, position =position_dodge(width =0.25)) +geom_violin(aes(fill = remove), alpha =0.3, position =position_dodge(width =0.25)) +# plotting distributionsstat_summary(fun.data ="mean_cl_normal", geom ="errorbar", position =position_dodge(width =0.25), width =0.2, size =1.5) +labs(x ="Relationship", y ="How much they would agree or disagree with the statement", title ="The legal system should consider getting rid of the law prohibiting the phantom rule.") +theme_minimal(base_size =15) +# Use a minimal themetheme(plot.title =element_text(hjust =0.5, size =17),axis.text.x =element_text(face ="plain", size =17, color ="black"),axis.text.y =element_text(face ="plain", size =25, color ="black"),axis.title.y =element_text(face ="plain", size =15, color ="black"), axis.title.x =element_text(face ="plain", size =30, color ="black"),panel.grid.major =element_line(color ="gray"), # Set major grid lines to graypanel.grid.minor =element_blank(), # Hide minor grid linespanel.background =element_rect(fill ="white", color ="white"),panel.border =element_rect(color ="black", fill =NA, size =1) ) +facet_wrap("scenario") +coord_cartesian(ylim =c(-100, 100)) +scale_y_continuous(breaks =c(-100, -50, 0, 50, 100)) #-100-100: -100, -50, 0, 50, 100print(remove_plot)
Assuming this person did break the rule, how would you rate their moral character?
Main plot + distribution
Code
moralP_plot <-ggplot(data_long, aes(x = relationship, y = moralP)) +geom_point(stat ="summary", fun ="mean", size =4, position =position_dodge(width =0.25)) +geom_violin(aes(fill = moralP), alpha =0.3, position =position_dodge(width =0.25)) +# plotting distributionsstat_summary(fun.data ="mean_cl_normal", geom ="errorbar", position =position_dodge(width =0.25), width =0.2, size =1.5) +labs(x ="Relationship", y ="Rating of moral character", title ="Assuming this person did break the rule, how would you rate their moral character?") +theme_minimal(base_size =15) +# Use a minimal themetheme(plot.title =element_text(hjust =0.5, size =17),axis.text.x =element_text(face ="plain", size =25, color ="black"),axis.text.y =element_text(face ="plain", size =25, color ="black"),axis.title.y =element_text(face ="plain", size =30, color ="black"), axis.title.x =element_text(face ="plain", size =30, color ="black"),panel.grid.major =element_line(color ="gray"), # Set major grid lines to graypanel.grid.minor =element_blank(), # Hide minor grid linespanel.background =element_rect(fill ="white", color ="white"),panel.border =element_rect(color ="black", fill =NA, size =1) ) +coord_cartesian(ylim =c(-100, 100)) +scale_y_continuous(breaks =c(-100, -50, 0, 50, 100)) #-100-100: -100, -50, 0, 50, 100print(moralP_plot)
Main plot + distribution for each scenario
Code
moralP_plot <-ggplot(data_long, aes(x = relationship, y = moralP)) +geom_point(stat ="summary", fun ="mean", size =4, position =position_dodge(width =0.25)) +geom_violin(aes(fill = moralP), alpha =0.3, position =position_dodge(width =0.25)) +# plotting distributionsstat_summary(fun.data ="mean_cl_normal", geom ="errorbar", position =position_dodge(width =0.25), width =0.2, size =1.5) +labs(x ="Relationship", y ="Rating of moral character", title ="Assuming this person did break the rule, how would you rate their moral character?") +theme_minimal(base_size =15) +# Use a minimal themetheme(plot.title =element_text(hjust =0.5, size =17),axis.text.x =element_text(face ="plain", size =17, color ="black"),axis.text.y =element_text(face ="plain", size =25, color ="black"),axis.title.y =element_text(face ="plain", size =30, color ="black"), axis.title.x =element_text(face ="plain", size =30, color ="black"),panel.grid.major =element_line(color ="gray"), # Set major grid lines to graypanel.grid.minor =element_blank(), # Hide minor grid linespanel.background =element_rect(fill ="white", color ="white"),panel.border =element_rect(color ="black", fill =NA, size =1) ) +facet_wrap("scenario") +coord_cartesian(ylim =c(-100, 100)) +scale_y_continuous(breaks =c(-100, -50, 0, 50, 100)) #-100-100: -100, -50, 0, 50, 100print(moralP_plot)
Source Code
---title: "Phantom Rule Pilot 1"author: 'Marcus, Amanda'date: "7/23/2024"format: html: code-fold: true code-tools: true fontsize: 16px self-contained: true toc: true toc-location: leftoutput: html_document: code_folding: hide number_sections: true toc: true toc_float: true toc_collapsed: true toc_depth: 3 keep_md: yes header-includes: - \usepackage{Roboto Condensed}knitr: opts_chunk: dev: ragg_pngexecute: warning: false---# Setup {.tabset .tabset-pills}## Libraries {.unlisted .unnumbered}```{r setup, message=F, results='hide', warning=FALSE}knitr::opts_chunk$set(warning = FALSE, message = FALSE) Mypackages <- c("lme4","tidyverse","effects","ggplot2","psych", "MASS","Rmisc","lmerTest","ggthemes", "knitr", "lsmeans","pastecs","sjstats","car","ordinal", "Rcpp","corrplot", "ggpubr", "EnvStats", "easyStats", "cowplot","see","datawizard", "ggcorrplot", "lavaan", "scales")#install.packages(Mypackages) #you must remove the # in this comment if you need to install the packages! lapply(Mypackages, require, character.only = TRUE)options(knitr.kable.NA = '—')set.seed(1) ```## Load Data```{r, message=F, results='hide', warning=FALSE}# read in data filessetwd("~/Desktop")data_raw <-read.csv("/Users/mtrenfield17/Desktop/Research/Boston College Research/Morality Lab Research/Phantom Rules Close Others/PILOT 1 Close Relationship Phantom Rules.csv")```## Functions```{r, message=F, results='hide', warning=FALSE}plot_cooker <- function(data, iv, dv) { part1 <- ggplot(data, aes(x = {{iv}}, y = {{dv}}, fill = {{iv}})) + geom_violin(alpha = 0.3, scale = "count") + stat_summary(fun = "mean", geom = "point", size = 3, color = "black") + stat_summary(fun.data = mean_cl_normal, geom = "errorbar", width = 0.2, #change to make a data set from allEffects with mean, low CI, high CI size = 1.5, color = "black") + theme_classic() + xlab("") + ylab("") ggpar(part1, legend = "none")}pol_line <- function(data, iv, dv) { ggplot(data, aes(x = {{iv}}, y = {{dv}}, color = condition)) + stat_summary(fun.data = "mean_cl_normal", geom = "line") + geom_point(position = position_jitter(width = 0.1, height = 0.1), alpha = 0.5) + labs(x = "Political Leaning", color = "Condition")}lizy_cooker <- function(dv, iv, Title, x_axis_labs, y_label, sample_size, coln, rown) { part1 <- ggviolin(gjg, x = dv, y = iv, color = dv, alpha = 0.1, fill = dv, xlab = "Motive", trim = TRUE, ylab = y_label) + stat_summary(fun.data = "mean_cl_normal", geom = "crossbar", fatten = 1) + scale_y_continuous(breaks = c(1:7)) + labs(title = paste0(Title, " (n = ", sample_size, ")")) + theme(panel.background = element_rect(fill = "transparent"), legend.position = "right", ## Consider “gray97” for fill plot.title = element_text(face = "bold", hjust = 0.5, size = 16), plot.subtitle = element_text(hjust = 0.5), panel.grid.major.y = element_line(color='grey75'), axis.text.x = element_text(face = "plain", size = 13, color = "black"), axis.text.y = element_text(face = "plain", size = 13, color = "black"), axis.title.y = element_text(face = "plain", size = 13, color = "black", margin = margin(t = 0, r = 10, b = 0, l = 0)), ## lower X axis title panel.border = element_rect(color = "black", fill = NA, size = 1)) + scale_color_discrete(name = "Condition") + facet_wrap(~ vignette, ncol = coln, nrow = rown, scales = "free", as.table = TRUE) ggpar(part1, legend = "none")}#POL_gjg_long <- filter(gjg_long, political_overall %in% c("Democrat", "Republican"))#gjg_long$political_overall#ggplot(gjg_long, aes(x = condition, y = p_approve, color = condition)) + #geom_point(stat="summary", fun="mean", size = 2) + #facet_wrap(~political_overall) + #scale_x_discrete(labels = NULL)```## Reshaping data```{r}# fixing typodata_raw$close1_code <-gsub("Romatic partner", "Romantic partner", data_raw$close1_code)data_raw$close2_code <-gsub("Romatic partner", "Romantic partner", data_raw$close2_code)data_raw$close3_code <-gsub("Romatic partner", "Romantic partner", data_raw$close3_code)# making conservative, liberal, and moderate group data_raw <- data_raw %>%mutate(political_group =ifelse(Political_overall >4, "Conservative",ifelse(Political_overall <4, "Liberal", "Moderate")))# making a column for white vs non-whitedata_raw$White <-ifelse(grepl("White", data_raw$Race_Ethnicity_TEXT), "White", "Non-White")# making a column for URM vs non-URMurm_groups <-c("Black", "Hispanic or Latino/a/x", "American Indian and Native Alaskan", "Pacific Islander or Native Hawaiian", "Middle Eastern and North African")data_raw$URM <-ifelse(grepl(paste(urm_groups, collapse="|"), data_raw$Race_Ethnicity_TEXT), "URM", "Non-URM")#### filtering people who failed the attn check ####data_raw$attn_self <-as.numeric(data_raw$attn_self)data <- data_raw %>%filter(attn_self >2)# Removing low quality datadata <- data %>%filter(!(prolificID %in%c("66574c6a2a79bcd8ac8a00e8", "662d15c45fc2c1ca89b362bf")))# changing numeric DVs to numericdata <- data %>%mutate_at(vars(loiter_interaction:jay_fair, Age), as.numeric)#### make dataset long ###data_long <- data %>%gather(stim, resp, "loiter_interaction":"jay_fair")data_long<-data_long %>%separate(stim, into=c("scenario", "DV"), sep="_")## shift dataset back to wide format ##data_long <-spread(data_long, DV, resp)# seperating the scenario order into their own columnsdata_long <- data_long %>%separate(scenario_order, into=c("first_scenario", "second_scenario", "third_scenario", "fourth_scenario", "fifth_scenario", "sixth_scenario"), sep="\\|")# renaming scenariosdata_long <- data_long %>%mutate(first_scenario =case_when( first_scenario =="FL_60"~"loiter", first_scenario =="FL_59"~"brights", first_scenario =="FL_57"~"jury", first_scenario =="FL_58"~"noise", first_scenario =="FL_56"~"music", first_scenario =="FL_55"~"jay",TRUE~ scenario))data_long <- data_long %>%mutate(second_scenario =case_when( second_scenario =="FL_60"~"loiter", second_scenario =="FL_59"~"brights", second_scenario =="FL_57"~"jury", second_scenario =="FL_58"~"noise", second_scenario =="FL_56"~"music", second_scenario =="FL_55"~"jay",TRUE~ scenario))data_long <- data_long %>%mutate(third_scenario =case_when( third_scenario =="FL_60"~"loiter", third_scenario =="FL_59"~"brights", third_scenario =="FL_57"~"jury", third_scenario =="FL_58"~"noise", third_scenario =="FL_56"~"music", third_scenario =="FL_55"~"jay",TRUE~ scenario))data_long <- data_long %>%mutate(fourth_scenario =case_when( fourth_scenario =="FL_60"~"loiter", fourth_scenario =="FL_59"~"brights", fourth_scenario =="FL_57"~"jury", fourth_scenario =="FL_58"~"noise", fourth_scenario =="FL_56"~"music", fourth_scenario =="FL_55"~"jay",TRUE~ scenario))data_long <- data_long %>%mutate(fifth_scenario =case_when( fifth_scenario =="FL_60"~"loiter", fifth_scenario =="FL_59"~"brights", fifth_scenario =="FL_57"~"jury", fifth_scenario =="FL_58"~"noise", fifth_scenario =="FL_56"~"music", fifth_scenario =="FL_55"~"jay",TRUE~ scenario))data_long <- data_long %>%mutate(sixth_scenario =case_when( sixth_scenario =="FL_60"~"loiter", sixth_scenario =="FL_59"~"brights", sixth_scenario =="FL_57"~"jury", sixth_scenario =="FL_58"~"noise", sixth_scenario =="FL_56"~"music", sixth_scenario =="FL_55"~"jay",TRUE~ scenario))# column for order the scenario was seendata_long <- data_long %>%mutate(presentation_order =case_when( scenario == first_scenario ~"first", scenario == second_scenario ~"second", scenario == third_scenario ~"third", scenario == fourth_scenario ~"fourth", scenario == fifth_scenario ~"fifth", scenario == sixth_scenario ~"sixth",TRUE~"not found" ))# column for whether the target was a stranger or close otherdata_long <- data_long %>%mutate(relationship =case_when( presentation_order =="first"& color_1 =="#FF5733"~"stranger", presentation_order =="first"& color_1 =="blue"~"close other", presentation_order =="second"& color_2 =="#FF5733"~"stranger", presentation_order =="second"& color_2 =="blue"~"close other", presentation_order =="third"& color_3 =="#FF5733"~"stranger", presentation_order =="third"& color_3 =="blue"~"close other", presentation_order =="fourth"& color_4 =="#FF5733"~"stranger", presentation_order =="fourth"& color_4 =="blue"~"close other", presentation_order =="fifth"& color_5 =="#FF5733"~"stranger", presentation_order =="fifth"& color_5 =="blue"~"close other", presentation_order =="sixth"& color_6 =="#FF5733"~"stranger", presentation_order =="sixth"& color_6 =="blue"~"close other",TRUE~"unknown" ))data_long <- data_long %>%mutate(corresponding_name =case_when( presentation_order =="first"~ name_1, presentation_order =="second"~ name_2, presentation_order =="third"~ name_3, presentation_order =="fourth"~ name_4, presentation_order =="fifth"~ name_5, presentation_order =="sixth"~ name_6,TRUE~NA_character_ ) )# Assign the appropriate relationship code or label as "stranger"data_long <- data_long %>%mutate(relationship_code =case_when( corresponding_name == close1_name ~ close1_code, corresponding_name == close2_name ~ close2_code, corresponding_name == close3_name ~ close3_code,TRUE~"stranger" ) )# column for how much participants like the close otherdata_long <- data_long %>%mutate(likeClose =case_when( corresponding_name == close1_name ~ likeClose1_1, corresponding_name == close2_name ~ likeClose2_1, corresponding_name == close3_name ~ likeClose3_1,TRUE~"n/a" ) )# making factor variables factorsdata_long <- data_long %>%mutate_at(vars(confront,didBreak,interaction, order,Gender), as.factor)```# Data Quality Checks* 2 low quality responses removed ## Attention Check* 0 people failed the attention check```{r, message=F, results='hide', warning=FALSE}data_attn_chk <- data_raw %>% filter(consent == 4)data_attn_chk %>% group_by(attn_self) %>% dplyr::summarise(n = n()) %>% mutate(freq = n / sum(n))```# Demographics```{r fig.dim = c(15, 13)}# putting the demos in the right orderdata <- data %>% mutate( Gender_TEXT = factor(Gender_TEXT, levels = c("Man", "Woman", "Nonbinary person", "An identity not listed")), Political_overall_TEXT = factor(Political_overall_TEXT, levels = c("Very liberal", "Liberal", "Somewhat liberal", "Moderate", "Somewhat conservative", "Conservative", "Very conservative")), political_group = factor(political_group, levels = c("Liberal", "Moderate", "Conservative")), White = factor(White, levels = c("White", "Non-White")), URM = factor(URM, levels = c("Non-URM", "URM")) )# Subset your data frame to include only the demographic columnsdemo_data <- data[, c("Gender_TEXT", "Race_Ethnicity_TEXT", "Political_overall_TEXT", "political_group", "White", "URM")]# Agemean(data$Age, na.rm=TRUE)sd(data$Age, na.rm=TRUE)# Loop through each demographic column and calculate frequency countsfreq_tables <- list()for (col in names(demo_data)) { { freq_table <- as.data.frame(table(demo_data[[col]])) freq_table$Percent <- round(freq_table$Freq / sum(freq_table$Freq) * 100, 2) freq_tables[[col]] <- freq_table }}# Print the frequency tablesfor (i in seq_along(freq_tables)) { if (!is.null(freq_tables[[i]])) { cat("\nTable of frequencies for", names(freq_tables)[i], ":\n") print(freq_tables[[i]]) }}```## Demographic Plot```{r}# List of demographic columns to plotdemographic_columns <-c("Gender_TEXT", "Political_overall_TEXT", "political_group", "White", "URM")# Function to create percent plotcreate_percent_plot <-function(data, column) {# Calculate the frequency and percentage for each category freq_table <- data %>%group_by(across(all_of(column))) %>% dplyr::summarise(Freq =n()) %>%mutate(Percent = Freq /sum(Freq) *100)# Create the plot p <-ggplot(freq_table, aes_string(x = column, y ="Percent", fill = column)) +geom_bar(stat ="identity", position ="dodge") +scale_y_continuous(labels = scales::percent_format(scale =1)) +labs(x = column, y ="Percentage", title =paste("Distribution of", column)) +theme_minimal() +theme(axis.text.x =element_text(angle =45, hjust =1))return(p)}# Loop through demographic columns and plotplots <-lapply(demographic_columns, function(col) create_percent_plot(demo_data, col))# Display the plotsprint(plots)```# Relationship Info## Relationship Type```{r}# Combine the columns close1_code, close2_code, and close3_code into one vectorall_relationships <-c(data$close1_code, data$close2_code, data$close3_code)# Count the occurrences of each unique relationship typerelationship_counts <-table(all_relationships)# Sort the counts in descending ordersorted_counts <-sort(relationship_counts, decreasing =TRUE)# Print the resultprint(sorted_counts)# Remove any instances of "n/a"all_relationships <- all_relationships[all_relationships !="n/a"]```## Relationship Closeness# Should police officer initiate interaction?## Main plot```{r}# Calculate proportionsdata_long_proportion <- data_long %>%group_by(relationship, interaction) %>% dplyr::summarise(count =n()) %>%mutate(proportion = count /sum(count))# Create the proportion plot with percentage y-axisInteraction_plot <-ggplot(data_long_proportion, aes(x=relationship, y=proportion, fill=factor(interaction))) +geom_bar(stat="identity", position="dodge") +scale_y_continuous(labels =percent_format()) +# Format y-axis as percentagescale_fill_manual(values =c("0"="#FF6F61", "1"="#4EC8BE"), # Customize the colors if desiredlabels =c("0"="No", "1"="Yes")) +# Change the legend labelsguides(fill =guide_legend(title =NULL)) +# Remove the legend titlelabs(x="Relationship", y="Percentage", title ="Should police officer initiate interaction?") +theme_minimal()# Print the plotprint(Interaction_plot)```### Statistical testing```{r}contingency_table <-table(data_long$relationship, data_long$interaction)# Print the contingency table to see the countsprint(contingency_table)# Perform the chi-square testchisq.test(contingency_table)stranger_data <- data_long %>%filter(relationship =="stranger")contingency_table <-table(stranger_data$relationship, stranger_data$interaction)# Print the contingency table to see the countsprint(contingency_table)# Perform the chi-square testchisq.test(contingency_table)# Calculate the count for each relationship and interactiondata_long %>%group_by(relationship) %>% dplyr::summarise(count =n()) %>%ungroup()data_long %>%group_by(relationship, scenario) %>% dplyr::summarise(count =n()) %>%ungroup()```## Plot for each scenario```{r}# Calculate proportionsdata_long_proportion <- data_long %>%group_by(relationship, scenario, interaction) %>% dplyr::summarise(count =n()) %>%mutate(proportion = count /sum(count))# Create the proportion plot with percentage y-axisInteraction_plot_facet <-ggplot(data_long_proportion, aes(x=relationship, y=proportion, fill=factor(interaction))) +geom_bar(stat="identity", position="dodge") +scale_y_continuous(labels =percent_format()) +# Format y-axis as percentagescale_fill_manual(values =c("0"="#FF6F61", "1"="#4EC8BE"), # Customize the colors if desiredlabels =c("0"="No", "1"="Yes")) +# Change the legend labelsguides(fill =guide_legend(title =NULL)) +# Remove the legend titlelabs(x="Relationship", y="Percentage", title ="Should police officer initiate interaction?") +theme_minimal() +facet_wrap("scenario")print(Interaction_plot_facet)```### Statistical testing```{r}jay_data <- data_long %>%filter(scenario =="jay")brights_data <- data_long %>%filter(scenario =="brights")jury_data <- data_long %>%filter(scenario =="jury")loiter_data <- data_long %>%filter(scenario =="loiter")music_data <- data_long %>%filter(scenario =="music")noise_data <- data_long %>%filter(scenario =="noise")contingency_table_jay <-table(jay_data$relationship, jay_data$interaction)contingency_table_brights <-table(brights_data$relationship, brights_data$interaction)contingency_table_jury <-table(jury_data$relationship, jury_data$interaction)contingency_table_loiter <-table(loiter_data$relationship, loiter_data$interaction)contingency_table_music <-table(music_data$relationship, music_data$interaction)contingency_table_noise <-table(noise_data$relationship, noise_data$interaction)# Print the contingency table to see the countsprint(contingency_table_jay)print(contingency_table_brights)print(contingency_table_jury)print(contingency_table_loiter)print(contingency_table_music)print(contingency_table_noise)# Perform the chi-square testchisq.test(contingency_table_jay)chisq.test(contingency_table_brights)chisq.test(contingency_table_jury)chisq.test(contingency_table_loiter)chisq.test(contingency_table_music)chisq.test(contingency_table_noise)```# Would you prefer to confront the person yourself, or have a police officer confront them?## Main plot```{r, fig.width=10, fig.height=8}# Calculate proportionsdata_long_proportion <- data_long %>% group_by(relationship, confront) %>% dplyr::summarise(count = n()) %>% mutate(proportion = count / sum(count))# Create the proportion plot with percentage y-axisconfront_plot <- ggplot(data_long_proportion, aes(x=relationship, y=proportion, fill=factor(confront))) + geom_bar(stat="identity", position="dodge") + scale_y_continuous(labels = percent_format()) + # Format y-axis as percentage scale_fill_manual(values = c("1" = "#8FCB9B", "2" = "#B39DDB"), # Customize the colors if desired labels = c("1" = "Confront them myself", "2" = "Have a police officer confront them")) + # Change the legend labels guides(fill = guide_legend(title = NULL)) + # Remove the legend title labs(x="Relationship", y="Percentage", title = "Would you prefer to confront the person yourself, or have a police officer confront them?") + theme_minimal()# Print the plotprint(confront_plot)```### Statistical testing```{r}contingency_table <-table(data_long$relationship, data_long$confront)# Print the contingency table to see the countsprint(contingency_table)# Perform the chi-square testchisq.test(contingency_table)```## Plot for each scenario```{r, fig.width=10, fig.height=8}# Calculate proportionsdata_long_proportion <- data_long %>% group_by(relationship, scenario, confront) %>% dplyr::summarise(count = n()) %>% mutate(proportion = count / sum(count))# Create the proportion plot with percentage y-axisconfront_facet_plot <- ggplot(data_long_proportion, aes(x=relationship, y=proportion, fill=factor(confront))) + geom_bar(stat="identity", position="dodge") + scale_y_continuous(labels = percent_format()) + # Format y-axis as percentage scale_fill_manual(values = c("1" = "#8FCB9B", "2" = "#B39DDB"), # Customize the colors if desired labels = c("1" = "Confront them myself", "2" = "Have a police officer confront them")) + # Change the legend labels guides(fill = guide_legend(title = NULL)) + # Remove the legend title labs(x="Relationship", y="Percentage", title = "Would you prefer to confront the person yourself, or have a police officer confront them?") + theme_minimal() + facet_wrap("scenario")# Print the plotprint(confront_facet_plot)```### Statistical testing```{r}contingency_table_jay <-table(jay_data$relationship, jay_data$confront)contingency_table_brights <-table(brights_data$relationship, brights_data$confront)contingency_table_jury <-table(jury_data$relationship, jury_data$confront)contingency_table_loiter <-table(loiter_data$relationship, loiter_data$confront)contingency_table_music <-table(music_data$relationship, music_data$confront)contingency_table_noise <-table(noise_data$relationship, noise_data$confront)# Print the contingency table to see the countsprint(contingency_table_jay)print(contingency_table_brights)print(contingency_table_jury)print(contingency_table_loiter)print(contingency_table_music)print(contingency_table_noise)# Perform the chi-square testchisq.test(contingency_table_jay)chisq.test(contingency_table_brights)chisq.test(contingency_table_jury)chisq.test(contingency_table_loiter)chisq.test(contingency_table_music)chisq.test(contingency_table_noise)```# Did this person break the rule?## Main plot```{r}# Calculate proportionsdata_long_proportion <- data_long %>%group_by(relationship, didBreak) %>% dplyr::summarise(count =n()) %>%mutate(proportion = count /sum(count))# Create the proportion plot with percentage y-axisdidBreak_plot <-ggplot(data_long_proportion, aes(x=relationship, y=proportion, fill=factor(didBreak))) +geom_bar(stat="identity", position="dodge") +scale_y_continuous(labels =percent_format()) +# Format y-axis as percentagescale_fill_manual(values =c("0"="#FF6F61", "1"="#4EC8BE"), # Customize the colors if desiredlabels =c("0"="No", "1"="Yes")) +# Change the legend labelsguides(fill =guide_legend(title =NULL)) +# Remove the legend titlelabs(x="Relationship", y="Percentage", title ="Did this person break the rule?") +theme_minimal()# Print the plotprint(didBreak_plot)```### Statistical testing```{r}contingency_table <-table(data_long$relationship, data_long$didBreak)# Print the contingency table to see the countsprint(contingency_table)# Perform the chi-square testchisq.test(contingency_table)```## Plot for each scenario```{r}# Calculate proportionsdata_long_proportion <- data_long %>%group_by(relationship, scenario, didBreak) %>% dplyr::summarise(count =n()) %>%mutate(proportion = count /sum(count))# Create the proportion plot with percentage y-axisdidBreak_facet_plot <-ggplot(data_long_proportion, aes(x=relationship, y=proportion, fill=factor(didBreak))) +geom_bar(stat="identity", position="dodge") +scale_y_continuous(labels =percent_format()) +# Format y-axis as percentagescale_fill_manual(values =c("0"="#FF6F61", "1"="#4EC8BE"), # Customize the colors if desiredlabels =c("0"="No", "1"="Yes")) +# Change the legend labelsguides(fill =guide_legend(title =NULL)) +# Remove the legend titlelabs(x="Relationship", y="Percentage", title ="Did this person break the rule?") +theme_minimal() +facet_wrap("scenario")# Print the plotprint(didBreak_facet_plot)```### Statistical testing```{r}contingency_table_jay <-table(jay_data$relationship, jay_data$didBreak)contingency_table_brights <-table(brights_data$relationship, brights_data$didBreak)contingency_table_jury <-table(jury_data$relationship, jury_data$didBreak)contingency_table_loiter <-table(loiter_data$relationship, loiter_data$didBreak)contingency_table_music <-table(music_data$relationship, music_data$didBreak)contingency_table_noise <-table(noise_data$relationship, noise_data$didBreak)# Print the contingency table to see the countsprint(contingency_table_jay)print(contingency_table_brights)print(contingency_table_jury)print(contingency_table_loiter)print(contingency_table_music)print(contingency_table_noise)# Perform the chi-square testchisq.test(contingency_table_jay)chisq.test(contingency_table_brights)chisq.test(contingency_table_jury)chisq.test(contingency_table_loiter)chisq.test(contingency_table_music)chisq.test(contingency_table_noise)```# Does punishing people who break the rule help maintain order?## Main plot```{r}# Calculate proportionsdata_long_proportion <- data_long %>%group_by(relationship, order) %>% dplyr::summarise(count =n()) %>%mutate(proportion = count /sum(count))# Create the proportion plot with percentage y-axisorder_plot <-ggplot(data_long_proportion, aes(x=relationship, y=proportion, fill=factor(order))) +geom_bar(stat="identity", position="dodge") +scale_y_continuous(labels =percent_format()) +# Format y-axis as percentagescale_fill_manual(values =c("0"="#FF6F61", "1"="#4EC8BE"), # Customize the colors if desiredlabels =c("0"="No", "1"="Yes")) +# Change the legend labelsguides(fill =guide_legend(title =NULL)) +# Remove the legend titlelabs(x="Relationship", y="Percentage", title ="Does punishing people who break the rule help maintain order?") +theme_minimal()# Print the plotprint(order_plot)```### Statistical testing```{r}contingency_table <-table(data_long$relationship, data_long$order)# Print the contingency table to see the countsprint(contingency_table)# Perform the chi-square testchisq.test(contingency_table)```## Plot for each scenario* jaywalking significant```{r}# Calculate proportionsdata_long_proportion <- data_long %>%group_by(relationship, scenario, order) %>% dplyr::summarise(count =n()) %>%mutate(proportion = count /sum(count))# Create the proportion plot with percentage y-axisorder_facet_plot <-ggplot(data_long_proportion, aes(x=relationship, y=proportion, fill=factor(order))) +geom_bar(stat="identity", position="dodge") +scale_y_continuous(labels =percent_format()) +# Format y-axis as percentagescale_fill_manual(values =c("0"="#FF6F61", "1"="#4EC8BE"), # Customize the colors if desiredlabels =c("0"="No", "1"="Yes")) +# Change the legend labelsguides(fill =guide_legend(title =NULL)) +# Remove the legend titlelabs(x="Relationship", y="Percentage", title ="Does punishing people who break the rule help maintain order?") +theme_minimal() +facet_wrap("scenario")print(order_facet_plot)```### Statistical testing```{r}contingency_table_jay <-table(jay_data$relationship, jay_data$order)contingency_table_brights <-table(brights_data$relationship, brights_data$order)contingency_table_jury <-table(jury_data$relationship, jury_data$order)contingency_table_loiter <-table(loiter_data$relationship, loiter_data$order)contingency_table_music <-table(music_data$relationship, music_data$order)contingency_table_noise <-table(noise_data$relationship, noise_data$order)# Print the contingency table to see the countsprint(contingency_table_jay)print(contingency_table_brights)print(contingency_table_jury)print(contingency_table_loiter)print(contingency_table_music)print(contingency_table_noise)# Perform the chi-square testchisq.test(contingency_table_jay)chisq.test(contingency_table_brights)chisq.test(contingency_table_jury)chisq.test(contingency_table_loiter)chisq.test(contingency_table_music)chisq.test(contingency_table_noise)```# Would you want to anonymously report this person? ## Main plot + distribution```{r, fig.width=10, fig.height=8}anonReport_plot <- ggplot(data_long, aes(x = relationship, y = anonReport)) + geom_point(stat = "summary", fun = "mean", size = 4, position = position_dodge(width = 0.25)) + geom_violin(aes(fill = anonReport), alpha = 0.3, position = position_dodge(width = 0.25)) + # plotting distributions stat_summary(fun.data = "mean_cl_normal", geom = "errorbar", position = position_dodge(width = 0.25), width = 0.2, size = 1.5) + labs(x = "Relationship", y = "Likelihood they would report", title = "Would you want to anonymously report this person?") + theme_minimal(base_size = 15) + # Use a minimal theme theme( plot.title = element_text(hjust = 0.5, size = 25), axis.text.x = element_text(face = "plain", size = 25, color = "black"), axis.text.y = element_text(face = "plain", size = 25, color = "black"), axis.title.y = element_text(face = "plain", size = 30, color = "black"), axis.title.x = element_text(face = "plain", size = 30, color = "black"), panel.grid.major = element_line(color = "gray"), # Set major grid lines to gray panel.grid.minor = element_blank(), # Hide minor grid lines panel.background = element_rect(fill = "white", color = "white"), panel.border = element_rect(color = "black", fill = NA, size = 1) ) + coord_cartesian(ylim = c(0, 100)) + scale_y_continuous(breaks = c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(anonReport_plot)```## Main plot + distribution for each scenario```{r, fig.width=10, fig.height=8}anonReport_plot <- ggplot(data_long, aes(x = relationship, y = anonReport)) + geom_point(stat = "summary", fun = "mean", size = 4, position = position_dodge(width = 0.25)) + geom_violin(aes(fill = anonReport), alpha = 0.3, position = position_dodge(width = 0.25)) + # plotting distributions stat_summary(fun.data = "mean_cl_normal", geom = "errorbar", position = position_dodge(width = 0.25), width = 0.2, size = 1.5) + labs(x = "Relationship", y = "Likelihood they would report", title = "Would you want to anonymously report this person?") + theme_minimal(base_size = 15) + # Use a minimal theme theme( plot.title = element_text(hjust = 0.5, size = 25), axis.text.x = element_text(face = "plain", size = 17, color = "black"), axis.text.y = element_text(face = "plain", size = 25, color = "black"), axis.title.y = element_text(face = "plain", size = 30, color = "black"), axis.title.x = element_text(face = "plain", size = 30, color = "black"), panel.grid.major = element_line(color = "gray"), # Set major grid lines to gray panel.grid.minor = element_blank(), # Hide minor grid lines panel.background = element_rect(fill = "white", color = "white"), panel.border = element_rect(color = "black", fill = NA, size = 1) ) + facet_wrap("scenario") + coord_cartesian(ylim = c(0, 100)) + scale_y_continuous(breaks = c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(anonReport_plot)```# Would you want to publicly report this person?## Main plot + distribution```{r, fig.width=10, fig.height=8}publicReport_plot <- ggplot(data_long, aes(x = relationship, y = publicReport)) + geom_point(stat = "summary", fun = "mean", size = 4, position = position_dodge(width = 0.25)) + geom_violin(aes(fill = publicReport), alpha = 0.3, position = position_dodge(width = 0.25)) + # plotting distributions stat_summary(fun.data = "mean_cl_normal", geom = "errorbar", position = position_dodge(width = 0.25), width = 0.2, size = 1.5) + labs(x = "Relationship", y = "Likelihood they would report", title = "Would you want to publicly report this person?") + theme_minimal(base_size = 15) + # Use a minimal theme theme( plot.title = element_text(hjust = 0.5, size = 25), axis.text.x = element_text(face = "plain", size = 25, color = "black"), axis.text.y = element_text(face = "plain", size = 25, color = "black"), axis.title.y = element_text(face = "plain", size = 30, color = "black"), axis.title.x = element_text(face = "plain", size = 30, color = "black"), panel.grid.major = element_line(color = "gray"), # Set major grid lines to gray panel.grid.minor = element_blank(), # Hide minor grid lines panel.background = element_rect(fill = "white", color = "white"), panel.border = element_rect(color = "black", fill = NA, size = 1) ) + coord_cartesian(ylim = c(0, 100)) + scale_y_continuous(breaks = c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(publicReport_plot)```## Main plot + distribution for each scenario```{r, fig.width=10, fig.height=8}publicReport_plot <- ggplot(data_long, aes(x = relationship, y = publicReport)) + geom_point(stat = "summary", fun = "mean", size = 4, position = position_dodge(width = 0.25)) + geom_violin(aes(fill = publicReport), alpha = 0.3, position = position_dodge(width = 0.25)) + # plotting distributions stat_summary(fun.data = "mean_cl_normal", geom = "errorbar", position = position_dodge(width = 0.25), width = 0.2, size = 1.5) + labs(x = "Relationship", y = "Likelihood they would report", title = "Would you want to publicly report this person?") + theme_minimal(base_size = 15) + # Use a minimal theme theme( plot.title = element_text(hjust = 0.5, size = 25), axis.text.x = element_text(face = "plain", size = 17, color = "black"), axis.text.y = element_text(face = "plain", size = 25, color = "black"), axis.title.y = element_text(face = "plain", size = 30, color = "black"), axis.title.x = element_text(face = "plain", size = 30, color = "black"), panel.grid.major = element_line(color = "gray"), # Set major grid lines to gray panel.grid.minor = element_blank(), # Hide minor grid lines panel.background = element_rect(fill = "white", color = "white"), panel.border = element_rect(color = "black", fill = NA, size = 1) ) + facet_wrap("scenario") + coord_cartesian(ylim = c(0, 100)) + scale_y_continuous(breaks = c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(publicReport_plot)```# Do you want this person to know that you reported him/her?## Main plot + distribution```{r, fig.width=10, fig.height=8}knowReport_plot <- ggplot(data_long, aes(x = relationship, y = knowReport)) + geom_point(stat = "summary", fun = "mean", size = 4, position = position_dodge(width = 0.25)) + geom_violin(aes(fill = knowReport), alpha = 0.3, position = position_dodge(width = 0.25)) + # plotting distributions stat_summary(fun.data = "mean_cl_normal", geom = "errorbar", position = position_dodge(width = 0.25), width = 0.2, size = 1.5) + labs(x = "Relationship", y = "Likelihood they want to be known it was them", title = "Do you want this person to know that you reported him/her?") + theme_minimal(base_size = 15) + # Use a minimal theme theme( plot.title = element_text(hjust = 0.5, size = 20), axis.text.x = element_text(face = "plain", size = 25, color = "black"), axis.text.y = element_text(face = "plain", size = 25, color = "black"), axis.title.y = element_text(face = "plain", size = 15, color = "black"), axis.title.x = element_text(face = "plain", size = 30, color = "black"), panel.grid.major = element_line(color = "gray"), # Set major grid lines to gray panel.grid.minor = element_blank(), # Hide minor grid lines panel.background = element_rect(fill = "white", color = "white"), panel.border = element_rect(color = "black", fill = NA, size = 1) ) + coord_cartesian(ylim = c(0, 100)) + scale_y_continuous(breaks = c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(knowReport_plot)```## Main plot + distribution for each scenario```{r, fig.width=10, fig.height=8}knowReport_plot <- ggplot(data_long, aes(x = relationship, y = knowReport)) + geom_point(stat = "summary", fun = "mean", size = 4, position = position_dodge(width = 0.25)) + geom_violin(aes(fill = knowReport), alpha = 0.3, position = position_dodge(width = 0.25)) + # plotting distributions stat_summary(fun.data = "mean_cl_normal", geom = "errorbar", position = position_dodge(width = 0.25), width = 0.2, size = 1.5) + labs(x = "Relationship", y = "Likelihood they want to be known it was them", title = "Do you want this person to know that you reported him/her?") + theme_minimal(base_size = 15) + # Use a minimal theme theme( plot.title = element_text(hjust = 0.5, size = 20), axis.text.x = element_text(face = "plain", size = 17, color = "black"), axis.text.y = element_text(face = "plain", size = 25, color = "black"), axis.title.y = element_text(face = "plain", size = 15, color = "black"), axis.title.x = element_text(face = "plain", size = 30, color = "black"), panel.grid.major = element_line(color = "gray"), # Set major grid lines to gray panel.grid.minor = element_blank(), # Hide minor grid lines panel.background = element_rect(fill = "white", color = "white"), panel.border = element_rect(color = "black", fill = NA, size = 1) ) + facet_wrap("scenario") + coord_cartesian(ylim = c(0, 100)) + scale_y_continuous(breaks = c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(knowReport_plot)```# How punishable is the act?## Main plot + distribution```{r, fig.width=10, fig.height=8}punish_plot <- ggplot(data_long, aes(x = relationship, y = punish)) + geom_point(stat = "summary", fun = "mean", size = 4, position = position_dodge(width = 0.25)) + geom_violin(aes(fill = punish), alpha = 0.3, position = position_dodge(width = 0.25)) + # plotting distributions stat_summary(fun.data = "mean_cl_normal", geom = "errorbar", position = position_dodge(width = 0.25), width = 0.2, size = 1.5) + labs(x = "Relationship", y = "How punishable they would report", title = "How punishable is the act?") + theme_minimal(base_size = 15) + # Use a minimal theme theme( plot.title = element_text(hjust = 0.5, size = 35), axis.text.x = element_text(face = "plain", size = 25, color = "black"), axis.text.y = element_text(face = "plain", size = 25, color = "black"), axis.title.y = element_text(face = "plain", size = 30, color = "black"), axis.title.x = element_text(face = "plain", size = 30, color = "black"), panel.grid.major = element_line(color = "gray"), # Set major grid lines to gray panel.grid.minor = element_blank(), # Hide minor grid lines panel.background = element_rect(fill = "white", color = "white"), panel.border = element_rect(color = "black", fill = NA, size = 1) ) + coord_cartesian(ylim = c(0, 100)) + scale_y_continuous(breaks = c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(punish_plot)```## Main plot + distribution for each scenario```{r, fig.width=10, fig.height=8}punish_plot <- ggplot(data_long, aes(x = relationship, y = punish)) + geom_point(stat = "summary", fun = "mean", size = 4, position = position_dodge(width = 0.25)) + geom_violin(aes(fill = punish), alpha = 0.3, position = position_dodge(width = 0.25)) + # plotting distributions stat_summary(fun.data = "mean_cl_normal", geom = "errorbar", position = position_dodge(width = 0.25), width = 0.2, size = 1.5) + labs(x = "Relationship", y = "How punishable they would report", title = "How punishable is the act?") + theme_minimal(base_size = 15) + # Use a minimal theme theme( plot.title = element_text(hjust = 0.5, size = 35), axis.text.x = element_text(face = "plain", size = 17, color = "black"), axis.text.y = element_text(face = "plain", size = 25, color = "black"), axis.title.y = element_text(face = "plain", size = 30, color = "black"), axis.title.x = element_text(face = "plain", size = 30, color = "black"), panel.grid.major = element_line(color = "gray"), # Set major grid lines to gray panel.grid.minor = element_blank(), # Hide minor grid lines panel.background = element_rect(fill = "white", color = "white"), panel.border = element_rect(color = "black", fill = NA, size = 1) ) + facet_wrap("scenario") + coord_cartesian(ylim = c(0, 100)) + scale_y_continuous(breaks = c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(punish_plot)```# How morally bad is the act?## Main plot + distribution```{r, fig.width=10, fig.height=8}moral_plot <- ggplot(data_long, aes(x = relationship, y = moral)) + geom_point(stat = "summary", fun = "mean", size = 4, position = position_dodge(width = 0.25)) + geom_violin(aes(fill = moral), alpha = 0.3, position = position_dodge(width = 0.25)) + # plotting distributions stat_summary(fun.data = "mean_cl_normal", geom = "errorbar", position = position_dodge(width = 0.25), width = 0.2, size = 1.5) + labs(x = "Relationship", y = "How morally bad they would report", title = "How morally bad is the act?") + theme_minimal(base_size = 15) + # Use a minimal theme theme( plot.title = element_text(hjust = 0.5, size = 35), axis.text.x = element_text(face = "plain", size = 25, color = "black"), axis.text.y = element_text(face = "plain", size = 25, color = "black"), axis.title.y = element_text(face = "plain", size = 30, color = "black"), axis.title.x = element_text(face = "plain", size = 30, color = "black"), panel.grid.major = element_line(color = "gray"), # Set major grid lines to gray panel.grid.minor = element_blank(), # Hide minor grid lines panel.background = element_rect(fill = "white", color = "white"), panel.border = element_rect(color = "black", fill = NA, size = 1) ) + coord_cartesian(ylim = c(0, 100)) + scale_y_continuous(breaks = c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(moral_plot)```## Main plot + distribution for each scenario```{r, fig.width=10, fig.height=8}moral_plot <- ggplot(data_long, aes(x = relationship, y = moral)) + geom_point(stat = "summary", fun = "mean", size = 4, position = position_dodge(width = 0.25)) + geom_violin(aes(fill = moral), alpha = 0.3, position = position_dodge(width = 0.25)) + # plotting distributions stat_summary(fun.data = "mean_cl_normal", geom = "errorbar", position = position_dodge(width = 0.25), width = 0.2, size = 1.5) + labs(x = "Relationship", y = "How morally bad they would report", title = "How morally bad is the act?") + theme_minimal(base_size = 15) + # Use a minimal theme theme( plot.title = element_text(hjust = 0.5, size = 35), axis.text.x = element_text(face = "plain", size = 17, color = "black"), axis.text.y = element_text(face = "plain", size = 25, color = "black"), axis.title.y = element_text(face = "plain", size = 30, color = "black"), axis.title.x = element_text(face = "plain", size = 30, color = "black"), panel.grid.major = element_line(color = "gray"), # Set major grid lines to gray panel.grid.minor = element_blank(), # Hide minor grid lines panel.background = element_rect(fill = "white", color = "white"), panel.border = element_rect(color = "black", fill = NA, size = 1) ) + facet_wrap("scenario") + coord_cartesian(ylim = c(0, 100)) + scale_y_continuous(breaks = c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(moral_plot)```# How justified is it for the legal system to be involved when a person violate a speficit phantom rule?## Main plot + distribution```{r, fig.width=10, fig.height=8}justified_plot <- ggplot(data_long, aes(x = relationship, y = justified)) + geom_point(stat = "summary", fun = "mean", size = 4, position = position_dodge(width = 0.25)) + geom_violin(aes(fill = justified), alpha = 0.3, position = position_dodge(width = 0.25)) + # plotting distributions stat_summary(fun.data = "mean_cl_normal", geom = "errorbar", position = position_dodge(width = 0.25), width = 0.2, size = 1.5) + labs(x = "Relationship", y = "Justified level", title = "How justified is it for the legal system to be involved when a person violate the rule?") + theme_minimal(base_size = 15) + # Use a minimal theme theme( plot.title = element_text(hjust = 0.5, size = 15), axis.text.x = element_text(face = "plain", size = 25, color = "black"), axis.text.y = element_text(face = "plain", size = 25, color = "black"), axis.title.y = element_text(face = "plain", size = 30, color = "black"), axis.title.x = element_text(face = "plain", size = 30, color = "black"), panel.grid.major = element_line(color = "gray"), # Set major grid lines to gray panel.grid.minor = element_blank(), # Hide minor grid lines panel.background = element_rect(fill = "white", color = "white"), panel.border = element_rect(color = "black", fill = NA, size = 1) ) + coord_cartesian(ylim = c(0, 100)) + scale_y_continuous(breaks = c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(justified_plot)```## Main plot + distribution for each scenario```{r, fig.width=10, fig.height=8}justified_plot <- ggplot(data_long, aes(x = relationship, y = justified)) + geom_point(stat = "summary", fun = "mean", size = 4, position = position_dodge(width = 0.25)) + geom_violin(aes(fill = justified), alpha = 0.3, position = position_dodge(width = 0.25)) + # plotting distributions stat_summary(fun.data = "mean_cl_normal", geom = "errorbar", position = position_dodge(width = 0.25), width = 0.2, size = 1.5) + labs(x = "Relationship", y = "Justified level", title = "How justified is it for the legal system to be involved when a person violate the rule?") + theme_minimal(base_size = 15) + # Use a minimal theme theme( plot.title = element_text(hjust = 0.5, size = 15), axis.text.x = element_text(face = "plain", size = 17, color = "black"), axis.text.y = element_text(face = "plain", size = 25, color = "black"), axis.title.y = element_text(face = "plain", size = 30, color = "black"), axis.title.x = element_text(face = "plain", size = 30, color = "black"), panel.grid.major = element_line(color = "gray"), # Set major grid lines to gray panel.grid.minor = element_blank(), # Hide minor grid lines panel.background = element_rect(fill = "white", color = "white"), panel.border = element_rect(color = "black", fill = NA, size = 1) ) + facet_wrap("scenario") + coord_cartesian(ylim = c(0, 100)) + scale_y_continuous(breaks = c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(justified_plot)```# How legitimate is the law against the rule?## Main plot + distribution```{r, fig.width=10, fig.height=8}legit_plot <- ggplot(data_long, aes(x = relationship, y = legit)) + geom_point(stat = "summary", fun = "mean", size = 4, position = position_dodge(width = 0.25)) + geom_violin(aes(fill = legit), alpha = 0.3, position = position_dodge(width = 0.25)) + # plotting distributions stat_summary(fun.data = "mean_cl_normal", geom = "errorbar", position = position_dodge(width = 0.25), width = 0.2, size = 1.5) + labs(x = "Relationship", y = "Legitimate level", title = "How legitimate is the law against the rule?") + theme_minimal(base_size = 15) + # Use a minimal theme theme( plot.title = element_text(hjust = 0.5, size = 30), axis.text.x = element_text(face = "plain", size = 25, color = "black"), axis.text.y = element_text(face = "plain", size = 25, color = "black"), axis.title.y = element_text(face = "plain", size = 30, color = "black"), axis.title.x = element_text(face = "plain", size = 30, color = "black"), panel.grid.major = element_line(color = "gray"), # Set major grid lines to gray panel.grid.minor = element_blank(), # Hide minor grid lines panel.background = element_rect(fill = "white", color = "white"), panel.border = element_rect(color = "black", fill = NA, size = 1) ) + coord_cartesian(ylim = c(0, 100)) + scale_y_continuous(breaks = c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(legit_plot)```## Main plot + distribution for each scenario```{r, fig.width=10, fig.height=8}legit_plot <- ggplot(data_long, aes(x = relationship, y = legit)) + geom_point(stat = "summary", fun = "mean", size = 4, position = position_dodge(width = 0.25)) + geom_violin(aes(fill = legit), alpha = 0.3, position = position_dodge(width = 0.25)) + # plotting distributions stat_summary(fun.data = "mean_cl_normal", geom = "errorbar", position = position_dodge(width = 0.25), width = 0.2, size = 1.5) + labs(x = "Relationship", y = "Legitimate level", title = "How legitimate is the law against the rule?") + theme_minimal(base_size = 15) + # Use a minimal theme theme( plot.title = element_text(hjust = 0.5, size = 30), axis.text.x = element_text(face = "plain", size = 17, color = "black"), axis.text.y = element_text(face = "plain", size = 25, color = "black"), axis.title.y = element_text(face = "plain", size = 30, color = "black"), axis.title.x = element_text(face = "plain", size = 30, color = "black"), panel.grid.major = element_line(color = "gray"), # Set major grid lines to gray panel.grid.minor = element_blank(), # Hide minor grid lines panel.background = element_rect(fill = "white", color = "white"), panel.border = element_rect(color = "black", fill = NA, size = 1) ) + facet_wrap("scenario") + coord_cartesian(ylim = c(0, 100)) + scale_y_continuous(breaks = c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(legit_plot)```# How fair is the law against the violation of the phantom rule?## Main plot + distribution```{r, fig.width=10, fig.height=8}fair_plot <- ggplot(data_long, aes(x = relationship, y = fair)) + geom_point(stat = "summary", fun = "mean", size = 4, position = position_dodge(width = 0.25)) + geom_violin(aes(fill = fair), alpha = 0.3, position = position_dodge(width = 0.25)) + # plotting distributions stat_summary(fun.data = "mean_cl_normal", geom = "errorbar", position = position_dodge(width = 0.25), width = 0.2, size = 1.5) + labs(x = "Relationship", y = "Fair level", title = "How fair is the law on the phantom rule?") + theme_minimal(base_size = 15) + # Use a minimal theme theme( plot.title = element_text(hjust = 0.5, size = 35), axis.text.x = element_text(face = "plain", size = 25, color = "black"), axis.text.y = element_text(face = "plain", size = 25, color = "black"), axis.title.y = element_text(face = "plain", size = 30, color = "black"), axis.title.x = element_text(face = "plain", size = 30, color = "black"), panel.grid.major = element_line(color = "gray"), # Set major grid lines to gray panel.grid.minor = element_blank(), # Hide minor grid lines panel.background = element_rect(fill = "white", color = "white"), panel.border = element_rect(color = "black", fill = NA, size = 1) ) + coord_cartesian(ylim = c(0, 100)) + scale_y_continuous(breaks = c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(fair_plot)```## Main plot + distribution for each scenario```{r, fig.width=10, fig.height=8}fair_plot <- ggplot(data_long, aes(x = relationship, y = fair)) + geom_point(stat = "summary", fun = "mean", size = 4, position = position_dodge(width = 0.25)) + geom_violin(aes(fill = fair), alpha = 0.3, position = position_dodge(width = 0.25)) + # plotting distributions stat_summary(fun.data = "mean_cl_normal", geom = "errorbar", position = position_dodge(width = 0.25), width = 0.2, size = 1.5) + labs(x = "Relationship", y = "Fair level", title = "How fair is the law on the phantom rule?") + theme_minimal(base_size = 15) + # Use a minimal theme theme( plot.title = element_text(hjust = 0.5, size = 35), axis.text.x = element_text(face = "plain", size = 17, color = "black"), axis.text.y = element_text(face = "plain", size = 25, color = "black"), axis.title.y = element_text(face = "plain", size = 30, color = "black"), axis.title.x = element_text(face = "plain", size = 30, color = "black"), panel.grid.major = element_line(color = "gray"), # Set major grid lines to gray panel.grid.minor = element_blank(), # Hide minor grid lines panel.background = element_rect(fill = "white", color = "white"), panel.border = element_rect(color = "black", fill = NA, size = 1) ) + facet_wrap("scenario") + coord_cartesian(ylim = c(0, 100)) + scale_y_continuous(breaks = c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(fair_plot)```# How likely is it that this person will break rules in the future?## Main plot + distribution```{r, fig.width=10, fig.height=8}breakP_plot <- ggplot(data_long, aes(x = relationship, y = breakP)) + geom_point(stat = "summary", fun = "mean", size = 4, position = position_dodge(width = 0.25)) + geom_violin(aes(fill = breakP), alpha = 0.3, position = position_dodge(width = 0.25)) + # plotting distributions stat_summary(fun.data = "mean_cl_normal", geom = "errorbar", position = position_dodge(width = 0.25), width = 0.2, size = 1.5) + labs(x = "Relationship", y = "Likelihood to break rule", title = "How likely is it that this person will break rules in the future?") + theme_minimal(base_size = 15) + # Use a minimal theme theme( plot.title = element_text(hjust = 0.5, size = 20), axis.text.x = element_text(face = "plain", size = 25, color = "black"), axis.text.y = element_text(face = "plain", size = 25, color = "black"), axis.title.y = element_text(face = "plain", size = 30, color = "black"), axis.title.x = element_text(face = "plain", size = 30, color = "black"), panel.grid.major = element_line(color = "gray"), # Set major grid lines to gray panel.grid.minor = element_blank(), # Hide minor grid lines panel.background = element_rect(fill = "white", color = "white"), panel.border = element_rect(color = "black", fill = NA, size = 1) ) + coord_cartesian(ylim = c(0, 100)) + scale_y_continuous(breaks = c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(breakP_plot)```## Main plot + distribution for each scenario```{r, fig.width=10, fig.height=8}breakP_plot <- ggplot(data_long, aes(x = relationship, y = breakP)) + geom_point(stat = "summary", fun = "mean", size = 4, position = position_dodge(width = 0.25)) + geom_violin(aes(fill = breakP), alpha = 0.3, position = position_dodge(width = 0.25)) + # plotting distributions stat_summary(fun.data = "mean_cl_normal", geom = "errorbar", position = position_dodge(width = 0.25), width = 0.2, size = 1.5) + labs(x = "Relationship", y = "Likelihood to break rule", title = "How likely is it that this person will break rules in the future?") + theme_minimal(base_size = 15) + # Use a minimal theme theme( plot.title = element_text(hjust = 0.5, size = 20), axis.text.x = element_text(face = "plain", size = 17, color = "black"), axis.text.y = element_text(face = "plain", size = 25, color = "black"), axis.title.y = element_text(face = "plain", size = 30, color = "black"), axis.title.x = element_text(face = "plain", size = 30, color = "black"), panel.grid.major = element_line(color = "gray"), # Set major grid lines to gray panel.grid.minor = element_blank(), # Hide minor grid lines panel.background = element_rect(fill = "white", color = "white"), panel.border = element_rect(color = "black", fill = NA, size = 1) ) + facet_wrap("scenario") + coord_cartesian(ylim = c(0, 100)) + scale_y_continuous(breaks = c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(breakP_plot)```# How much do you feel the actions of this person were harmful to others?## Main plot + distribution```{r, fig.width=10, fig.height=8}harmP_plot <- ggplot(data_long, aes(x = relationship, y = harmP)) + geom_point(stat = "summary", fun = "mean", size = 4, position = position_dodge(width = 0.25)) + geom_violin(aes(fill = harmP), alpha = 0.3, position = position_dodge(width = 0.25)) + # plotting distributions stat_summary(fun.data = "mean_cl_normal", geom = "errorbar", position = position_dodge(width = 0.25), width = 0.2, size = 1.5) + labs(x = "Relationship", y = "Level of harmfulness", title = "How much do you feel the actions of this person were harmful to others?") + theme_minimal(base_size = 15) + # Use a minimal theme theme( plot.title = element_text(hjust = 0.5, size = 20), axis.text.x = element_text(face = "plain", size = 25, color = "black"), axis.text.y = element_text(face = "plain", size = 25, color = "black"), axis.title.y = element_text(face = "plain", size = 30, color = "black"), axis.title.x = element_text(face = "plain", size = 30, color = "black"), panel.grid.major = element_line(color = "gray"), # Set major grid lines to gray panel.grid.minor = element_blank(), # Hide minor grid lines panel.background = element_rect(fill = "white", color = "white"), panel.border = element_rect(color = "black", fill = NA, size = 1) ) + coord_cartesian(ylim = c(0, 100)) + scale_y_continuous(breaks = c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(harmP_plot)```## Main plot + distribution for each scenario```{r, fig.width=10, fig.height=8}harmP_plot <- ggplot(data_long, aes(x = relationship, y = harmP)) + geom_point(stat = "summary", fun = "mean", size = 4, position = position_dodge(width = 0.25)) + geom_violin(aes(fill = harmP), alpha = 0.3, position = position_dodge(width = 0.25)) + # plotting distributions stat_summary(fun.data = "mean_cl_normal", geom = "errorbar", position = position_dodge(width = 0.25), width = 0.2, size = 1.5) + labs(x = "Relationship", y = "Level of harmfulness", title = "How much do you feel the actions of this person were harmful to others?") + theme_minimal(base_size = 15) + # Use a minimal theme theme( plot.title = element_text(hjust = 0.5, size = 20), axis.text.x = element_text(face = "plain", size = 17, color = "black"), axis.text.y = element_text(face = "plain", size = 25, color = "black"), axis.title.y = element_text(face = "plain", size = 30, color = "black"), axis.title.x = element_text(face = "plain", size = 30, color = "black"), panel.grid.major = element_line(color = "gray"), # Set major grid lines to gray panel.grid.minor = element_blank(), # Hide minor grid lines panel.background = element_rect(fill = "white", color = "white"), panel.border = element_rect(color = "black", fill = NA, size = 1) ) + facet_wrap("scenario") + coord_cartesian(ylim = c(0, 100)) + scale_y_continuous(breaks = c(25,50,75,100)) #-100-100: -100, -50, 0, 50, 100print(harmP_plot)```# Should the legal system consider getting rid of the law prohibiting the phantom rule?## Main plot + distribution```{r, fig.width=10, fig.height=8}remove_plot <- ggplot(data_long, aes(x = relationship, y = remove)) + geom_point(stat = "summary", fun = "mean", size = 4, position = position_dodge(width = 0.25)) + geom_violin(aes(fill = remove), alpha = 0.3, position = position_dodge(width = 0.25)) + # plotting distributions stat_summary(fun.data = "mean_cl_normal", geom = "errorbar", position = position_dodge(width = 0.25), width = 0.2, size = 1.5) + labs(x = "Relationship", y = "How much they would agree or disagree with the statement", title = "The legal system should consider getting rid of the law prohibiting the phantom rule.") + theme_minimal(base_size = 15) + # Use a minimal theme theme( plot.title = element_text(hjust = 0.5, size = 17), axis.text.x = element_text(face = "plain", size = 25, color = "black"), axis.text.y = element_text(face = "plain", size = 25, color = "black"), axis.title.y = element_text(face = "plain", size = 15, color = "black"), axis.title.x = element_text(face = "plain", size = 30, color = "black"), panel.grid.major = element_line(color = "gray"), # Set major grid lines to gray panel.grid.minor = element_blank(), # Hide minor grid lines panel.background = element_rect(fill = "white", color = "white"), panel.border = element_rect(color = "black", fill = NA, size = 1) ) + coord_cartesian(ylim = c(-100, 100)) + scale_y_continuous(breaks = c(-100, -50, 0, 50, 100)) #-100-100: -100, -50, 0, 50, 100print(remove_plot)```## Main plot + distribution for each scenario```{r, fig.width=10, fig.height=8}remove_plot <- ggplot(data_long, aes(x = relationship, y = remove)) + geom_point(stat = "summary", fun = "mean", size = 4, position = position_dodge(width = 0.25)) + geom_violin(aes(fill = remove), alpha = 0.3, position = position_dodge(width = 0.25)) + # plotting distributions stat_summary(fun.data = "mean_cl_normal", geom = "errorbar", position = position_dodge(width = 0.25), width = 0.2, size = 1.5) + labs(x = "Relationship", y = "How much they would agree or disagree with the statement", title = "The legal system should consider getting rid of the law prohibiting the phantom rule.") + theme_minimal(base_size = 15) + # Use a minimal theme theme( plot.title = element_text(hjust = 0.5, size = 17), axis.text.x = element_text(face = "plain", size = 17, color = "black"), axis.text.y = element_text(face = "plain", size = 25, color = "black"), axis.title.y = element_text(face = "plain", size = 15, color = "black"), axis.title.x = element_text(face = "plain", size = 30, color = "black"), panel.grid.major = element_line(color = "gray"), # Set major grid lines to gray panel.grid.minor = element_blank(), # Hide minor grid lines panel.background = element_rect(fill = "white", color = "white"), panel.border = element_rect(color = "black", fill = NA, size = 1) ) + facet_wrap("scenario") + coord_cartesian(ylim = c(-100, 100)) + scale_y_continuous(breaks = c(-100, -50, 0, 50, 100)) #-100-100: -100, -50, 0, 50, 100print(remove_plot)```# Assuming this person did break the rule, how would you rate their moral character?## Main plot + distribution```{r, fig.width=10, fig.height=8}moralP_plot <- ggplot(data_long, aes(x = relationship, y = moralP)) + geom_point(stat = "summary", fun = "mean", size = 4, position = position_dodge(width = 0.25)) + geom_violin(aes(fill = moralP), alpha = 0.3, position = position_dodge(width = 0.25)) + # plotting distributions stat_summary(fun.data = "mean_cl_normal", geom = "errorbar", position = position_dodge(width = 0.25), width = 0.2, size = 1.5) + labs(x = "Relationship", y = "Rating of moral character", title = "Assuming this person did break the rule, how would you rate their moral character?") + theme_minimal(base_size = 15) + # Use a minimal theme theme( plot.title = element_text(hjust = 0.5, size = 17), axis.text.x = element_text(face = "plain", size = 25, color = "black"), axis.text.y = element_text(face = "plain", size = 25, color = "black"), axis.title.y = element_text(face = "plain", size = 30, color = "black"), axis.title.x = element_text(face = "plain", size = 30, color = "black"), panel.grid.major = element_line(color = "gray"), # Set major grid lines to gray panel.grid.minor = element_blank(), # Hide minor grid lines panel.background = element_rect(fill = "white", color = "white"), panel.border = element_rect(color = "black", fill = NA, size = 1) ) + coord_cartesian(ylim = c(-100, 100)) + scale_y_continuous(breaks = c(-100, -50, 0, 50, 100)) #-100-100: -100, -50, 0, 50, 100print(moralP_plot)```## Main plot + distribution for each scenario```{r, fig.width=10, fig.height=8}moralP_plot <- ggplot(data_long, aes(x = relationship, y = moralP)) + geom_point(stat = "summary", fun = "mean", size = 4, position = position_dodge(width = 0.25)) + geom_violin(aes(fill = moralP), alpha = 0.3, position = position_dodge(width = 0.25)) + # plotting distributions stat_summary(fun.data = "mean_cl_normal", geom = "errorbar", position = position_dodge(width = 0.25), width = 0.2, size = 1.5) + labs(x = "Relationship", y = "Rating of moral character", title = "Assuming this person did break the rule, how would you rate their moral character?") + theme_minimal(base_size = 15) + # Use a minimal theme theme( plot.title = element_text(hjust = 0.5, size = 17), axis.text.x = element_text(face = "plain", size = 17, color = "black"), axis.text.y = element_text(face = "plain", size = 25, color = "black"), axis.title.y = element_text(face = "plain", size = 30, color = "black"), axis.title.x = element_text(face = "plain", size = 30, color = "black"), panel.grid.major = element_line(color = "gray"), # Set major grid lines to gray panel.grid.minor = element_blank(), # Hide minor grid lines panel.background = element_rect(fill = "white", color = "white"), panel.border = element_rect(color = "black", fill = NA, size = 1) ) + facet_wrap("scenario") + coord_cartesian(ylim = c(-100, 100)) + scale_y_continuous(breaks = c(-100, -50, 0, 50, 100)) #-100-100: -100, -50, 0, 50, 100print(moralP_plot)```