Packages and Data

# Load in packages
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
# Read in data
pilotdata <- read_csv("pilotdata_all.csv")
## New names:
## Rows: 105 Columns: 142
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (1): Q35 dbl (141): relationship, followpol, PO, educ, PA, gender, age, Q6_1,
## Q6_2, Q...
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `Q22_1` -> `Q22_1...30`
## • `Q22_2` -> `Q22_2...31`
## • `Q22_3` -> `Q22_3...32`
## • `Q22_4` -> `Q22_4...33`
## • `Q22_5` -> `Q22_5...34`
## • `Q22_1` -> `Q22_1...67`
## • `Q22_2` -> `Q22_2...68`
## • `Q22_3` -> `Q22_3...69`
## • `Q22_4` -> `Q22_4...70`
## • `Q22_5` -> `Q22_5...71`
# Change char to num
pilotdata <- pilotdata %>%
  mutate(across(where(is.factor), ~ as.numeric(as.character(.))))

Controversial Replication

# Filter political affiliation (Democrat = 1, Republican = 2, Independent = 3) and select controversial topics columns
Ds <- pilotdata %>% filter(PA == 1) %>% select(matches("^Q6_\\d+$"))
Rs <- pilotdata %>% filter(PA == 2) %>% select(matches("^Q6_\\d+$"))
Is <- pilotdata %>% filter(PA == 3) %>% select(matches("^Q6_\\d+$"))

# Find means
overallmeans <- pilotdata %>%
  select(matches("^Q6_\\d+$")) %>%
  colMeans(na.rm = TRUE)
Dmeans <- colMeans(Ds, na.rm = TRUE)
Rmeans <- colMeans(Rs, na.rm = TRUE)
Imeans <- colMeans(Is, na.rm = TRUE)

# Combine means into a dataframe
means_df <- data.frame(
  Topic = paste0("Q6_", 1:22),
  OverallMean = overallmeans,
  Dmean = Dmeans,
  Rmean = Rmeans,
  Imean = Imeans
)

# Filter controversial topics for means above 4
controversial_topics <- means_df %>%
  filter(OverallMean >= 4, Dmean >= 4, Rmean >= 4, Imean >= 4)

# Print list of controversial topics
print(controversial_topics)
##       Topic OverallMean    Dmean    Rmean    Imean
## Q6_1   Q6_1    5.250000 5.222222 5.212121 5.260870
## Q6_2   Q6_2    5.504762 5.760870 5.424242 5.217391
## Q6_3   Q6_3    5.761905 5.804348 5.969697 5.304348
## Q6_5   Q6_5    4.685714 4.608696 4.909091 4.521739
## Q6_6   Q6_6    4.865385 4.755556 4.878788 4.869565
## Q6_7   Q6_7    4.923077 4.956522 5.030303 4.727273
## Q6_8   Q6_8    5.009524 4.891304 5.303030 4.695652
## Q6_9   Q6_9    4.904762 5.000000 4.757576 4.826087
## Q6_10 Q6_10    5.123810 5.065217 5.333333 4.826087
## Q6_11 Q6_11    5.257143 5.478261 5.424242 4.739130
## Q6_13 Q6_13    5.211538 5.488889 5.030303 4.956522
## Q6_14 Q6_14    4.904762 5.065217 5.030303 4.304348
## Q6_15 Q6_15    5.352381 5.369565 5.363636 5.217391
## Q6_16 Q6_16    4.276190 4.152174 4.636364 4.043478
## Q6_17 Q6_17    4.567308 4.434783 4.843750 4.347826
## Q6_18 Q6_18    4.586538 4.565217 4.906250 4.130435
## Q6_19 Q6_19    4.952381 5.043478 4.818182 4.869565
## Q6_20 Q6_20    5.790476 5.739130 5.696970 5.956522
## Q6_21 Q6_21    4.942857 4.956522 5.272727 4.304348
## Q6_22 Q6_22    5.104762 5.108696 4.969697 5.130435
# Filter excluded topics for means above 4
excluded_topics <- means_df %>%
  filter(OverallMean < 4 | Dmean < 4 | Rmean < 4 | Imean < 4)

# Print list of excluded topics
print(excluded_topics)
##       Topic OverallMean    Dmean    Rmean    Imean
## Q6_4   Q6_4    4.371429 4.782609 4.454545 3.347826
## Q6_12 Q6_12    4.596154 4.711111 4.909091 3.739130