Phantom Rule Pilot 1

Author

Marcus, Amanda

Published

July 23, 2024

Setup

Libraries

Code
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 files
setwd("~/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 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

Code
# fixing typo
data_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-white
data_raw$White <- ifelse(grepl("White", data_raw$Race_Ethnicity_TEXT), "White", "Non-White")

# making a column for URM vs non-URM
urm_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 data
data <- data %>% filter(!(prolificID %in% c("66574c6a2a79bcd8ac8a00e8", "662d15c45fc2c1ca89b362bf")))

# changing numeric DVs to numeric
data <- 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 columns
data_long <- data_long %>%
  separate(scenario_order, into= c("first_scenario", "second_scenario", "third_scenario", "fourth_scenario", "fifth_scenario", "sixth_scenario"), sep="\\|")

# renaming scenarios
data_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 seen
data_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 other
data_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 other
data_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 factors
data_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
Code
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

Code
# putting the demos in the right order
data <- 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 columns
demo_data <- data[, c("Gender_TEXT", "Race_Ethnicity_TEXT", "Political_overall_TEXT", "political_group", "White", "URM")]

# Age
mean(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 counts
freq_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 tables
for (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]])
  }
}

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 plot
demographic_columns <- c("Gender_TEXT", "Political_overall_TEXT", "political_group", "White", "URM")

# Function to create percent plot
create_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 plot
plots <- lapply(demographic_columns, function(col) create_percent_plot(demo_data, col))

# Display the plots
print(plots)
[[1]]


[[2]]


[[3]]


[[4]]


[[5]]

Relationship Info

Relationship Type

Code
# Combine the columns close1_code, close2_code, and close3_code into one vector
all_relationships <- c(data$close1_code, data$close2_code, data$close3_code)

# Count the occurrences of each unique relationship type
relationship_counts <- table(all_relationships)

# Sort the counts in descending order
sorted_counts <- sort(relationship_counts, decreasing = TRUE)

# Print the result
print(sorted_counts)
all_relationships
          Family           Friend Romantic partner              n/a 
             198              147               90                7 
        Coworker 
               2 
Code
# 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 proportions
data_long_proportion <- data_long %>%
  group_by(relationship, interaction) %>%
  dplyr::summarise(count = n()) %>%
  mutate(proportion = count / sum(count))

# Create the proportion plot with percentage y-axis
Interaction_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 percentage
  scale_fill_manual(values = c("0" = "#FF6F61", "1" = "#4EC8BE"),  # Customize the colors if desired
                    labels = c("0" = "No", "1" = "Yes")) +  # Change the legend labels
  guides(fill = guide_legend(title = NULL)) +  # Remove the legend title
  labs(x="Relationship", y="Percentage", title = "Should police officer initiate interaction?") +
  theme_minimal()

# Print the plot
print(Interaction_plot)

Statistical testing

Code
contingency_table <- table(data_long$relationship, data_long$interaction)

# Print the contingency table to see the counts
print(contingency_table)
             
                0   1
  close other 222 222
  stranger    214 230
Code
# Perform the chi-square test
chisq.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 counts
print(contingency_table)
          
             0   1
  stranger 214 230
Code
# Perform the chi-square test
chisq.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 interaction
data_long %>%
  group_by(relationship) %>%
  dplyr::summarise(count = n()) %>%
  ungroup()
# A tibble: 2 × 2
  relationship count
  <chr>        <int>
1 close other    444
2 stranger       444
Code
data_long %>%
  group_by(relationship, scenario) %>%
  dplyr::summarise(count = n()) %>%
  ungroup()
# 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 proportions
data_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-axis
Interaction_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 percentage
  scale_fill_manual(values = c("0" = "#FF6F61", "1" = "#4EC8BE"),  # Customize the colors if desired
                    labels = c("0" = "No", "1" = "Yes")) +  # Change the legend labels
  guides(fill = guide_legend(title = NULL)) +  # Remove the legend title
  labs(x="Relationship", y="Percentage", title = "Should police officer initiate interaction?") +
  theme_minimal() + 
  facet_wrap("scenario")

print(Interaction_plot_facet)

Statistical testing

Code
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 counts
print(contingency_table_jay)
             
               0  1
  close other 32 40
  stranger    41 35
Code
print(contingency_table_brights)
             
               0  1
  close other 33 45
  stranger    20 50
Code
print(contingency_table_jury)
             
               0  1
  close other 45 26
  stranger    44 33
Code
print(contingency_table_loiter)
             
               0  1
  close other 46 32
  stranger    43 27
Code
print(contingency_table_music)
             
               0  1
  close other 50 24
  stranger    50 24
Code
print(contingency_table_noise)
             
               0  1
  close other 16 55
  stranger    16 61
Code
# Perform the chi-square test
chisq.test(contingency_table_jay)

    Pearson's Chi-squared test with Yates' continuity correction

data:  contingency_table_jay
X-squared = 0.98266, df = 1, p-value = 0.3215
Code
chisq.test(contingency_table_brights)

    Pearson's Chi-squared test with Yates' continuity correction

data:  contingency_table_brights
X-squared = 2.4602, df = 1, p-value = 0.1168
Code
chisq.test(contingency_table_jury)

    Pearson's Chi-squared test with Yates' continuity correction

data:  contingency_table_jury
X-squared = 0.36753, df = 1, p-value = 0.5444
Code
chisq.test(contingency_table_loiter)

    Pearson's Chi-squared test with Yates' continuity correction

data:  contingency_table_loiter
X-squared = 0.018584, df = 1, p-value = 0.8916
Code
chisq.test(contingency_table_music)

    Pearson's Chi-squared test

data:  contingency_table_music
X-squared = 0, df = 1, p-value = 1
Code
chisq.test(contingency_table_noise)

    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 proportions
data_long_proportion <- data_long %>%
  group_by(relationship, confront) %>%
  dplyr::summarise(count = n()) %>%
  mutate(proportion = count / sum(count))

# Create the proportion plot with percentage y-axis
confront_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 plot
print(confront_plot)

Statistical testing

Code
contingency_table <- table(data_long$relationship, data_long$confront)

# Print the contingency table to see the counts
print(contingency_table)
             
                1   2
  close other 265 179
  stranger    254 190
Code
# Perform the chi-square test
chisq.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 proportions
data_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-axis
confront_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 plot
print(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 counts
print(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 test
chisq.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 proportions
data_long_proportion <- data_long %>%
  group_by(relationship, didBreak) %>%
  dplyr::summarise(count = n()) %>%
  mutate(proportion = count / sum(count))

# Create the proportion plot with percentage y-axis
didBreak_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 percentage
  scale_fill_manual(values = c("0" = "#FF6F61", "1" = "#4EC8BE"),  # Customize the colors if desired
                    labels = c("0" = "No", "1" = "Yes")) +  # Change the legend labels
  guides(fill = guide_legend(title = NULL)) +  # Remove the legend title
  labs(x="Relationship", y="Percentage", title = "Did this person break the rule?") +
  theme_minimal()

# Print the plot
print(didBreak_plot)

Statistical testing

Code
contingency_table <- table(data_long$relationship, data_long$didBreak)

# Print the contingency table to see the counts
print(contingency_table)
             
                0   1
  close other  53 391
  stranger     47 397
Code
# Perform the chi-square test
chisq.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 proportions
data_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-axis
didBreak_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 percentage
  scale_fill_manual(values = c("0" = "#FF6F61", "1" = "#4EC8BE"),  # Customize the colors if desired
                    labels = c("0" = "No", "1" = "Yes")) +  # Change the legend labels
  guides(fill = guide_legend(title = NULL)) +  # Remove the legend title
  labs(x="Relationship", y="Percentage", title = "Did this person break the rule?") +
  theme_minimal() +
  facet_wrap("scenario")

# Print the plot
print(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 counts
print(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 test
chisq.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 proportions
data_long_proportion <- data_long %>%
  group_by(relationship, order) %>%
  dplyr::summarise(count = n()) %>%
  mutate(proportion = count / sum(count))

# Create the proportion plot with percentage y-axis
order_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 percentage
  scale_fill_manual(values = c("0" = "#FF6F61", "1" = "#4EC8BE"),  # Customize the colors if desired
                    labels = c("0" = "No", "1" = "Yes")) +  # Change the legend labels
  guides(fill = guide_legend(title = NULL)) +  # Remove the legend title
  labs(x="Relationship", y="Percentage", title = "Does punishing people who break the rule help maintain order?") +
  theme_minimal()

# Print the plot
print(order_plot)

Statistical testing

Code
contingency_table <- table(data_long$relationship, data_long$order)

# Print the contingency table to see the counts
print(contingency_table)
             
                0   1
  close other 197 247
  stranger    206 238
Code
# Perform the chi-square test
chisq.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 proportions
data_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-axis
order_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 percentage
  scale_fill_manual(values = c("0" = "#FF6F61", "1" = "#4EC8BE"),  # Customize the colors if desired
                    labels = c("0" = "No", "1" = "Yes")) +  # Change the legend labels
  guides(fill = guide_legend(title = NULL)) +  # Remove the legend title
  labs(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 counts
print(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 test
chisq.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 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, 100
print(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 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, 100
print(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 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, 100
print(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 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, 100
print(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 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, 100
print(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 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, 100
print(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 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, 100
print(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 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, 100
print(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 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, 100
print(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 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, 100
print(moral_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 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, 100
print(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 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, 100
print(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 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, 100
print(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 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, 100
print(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 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, 100
print(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 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, 100
print(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 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, 100
print(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 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, 100
print(harmP_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 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, 100
print(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 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, 100
print(moralP_plot)