# Clear environment and set working directoryrm(list =ls())setwd("~/Downloads/beliefchange")# Load required librarieslibrary(tidyverse)
Warning: package 'purrr' was built under R version 4.3.3
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.2 ✔ readr 2.1.4
✔ forcats 1.0.0 ✔ stringr 1.5.1
✔ ggplot2 3.5.1 ✔ tibble 3.2.1
✔ lubridate 1.9.2 ✔ tidyr 1.3.0
✔ purrr 1.0.4
── 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
library(psych)
Attaching package: 'psych'
The following objects are masked from 'package:ggplot2':
%+%, alpha
library(broom)library(gt)
Warning: package 'gt' was built under R version 4.3.3
library(lubridate)library(effectsize)
Warning: package 'effectsize' was built under R version 4.3.3
Attaching package: 'effectsize'
The following object is masked from 'package:psych':
phi
library(labelled)
Warning: package 'labelled' was built under R version 4.3.3
1. Load and preprocess raw data
# Read raw fileraw <-read_csv("beliefchange_fullstudy.csv", col_names =FALSE)
Rows: 811 Columns: 102
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (102): X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15,...
ℹ 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.
# Extract variable names and labelsvarnames <- raw |>slice(1) |>unlist() |>as.character()varlabels <- raw |>slice(2) |>unlist() |>as.character()# Apply names and labelsraw <- raw |>slice(-1:-3) |>set_names(varnames) |>set_variable_labels(.labels =setNames(varlabels, varnames))df <- raw |>select(-socialissue) |># this var is only the last social issue ps receivedrename(condition = cond) |># Experimental conditionmutate(StartDate =ymd_hms(StartDate),across(matches("(_believe|_honest|_genuine|_stick)$"), as.numeric),attn_check_8 =as.numeric(attn_check_8),age =as.numeric(age),gender =factor(gender,levels =c("1","2","3","4"),labels =c("Man","Woman","Nonbinary/Agender","Other")),political_party =factor(political_party,levels =c("1","2","3","4"),labels =c("Democrat","Republican","Independent","None")),condition =factor(condition, levels =c("shortinfo", "longinfo", "shorttime", "longtime"),labels =c("Small Amount of Info", "Large Amount of Info","Small Reflection Time", "Large Reflection Time")),# Study 1 = Amount of Info ; Study 2 = Reflection Timestudy =if_else(str_detect(condition, "Info"), "Amount of Info", "Reflection Time"),amount =factor(if_else(str_detect(condition, "Small"), "Small", "Large"),levels =c("Small", "Large")),# Genuineness indices for each social issueim_gidx = (im_believe + im_genuine + im_honest) /3,ca_gidx = (ca_believe + ca_genuine + ca_honest) /3,gc_gidx = (gc_believe + gc_genuine + gc_honest) /3,dp_gidx = (dp_believe + dp_genuine + dp_honest) /3,tr_gidx = (tr_believe + tr_genuine + tr_honest) /3 ) |># remove test responsesfilter(DistributionChannel =="anonymous", prolific_id_1 !="test")
Small Amount of Info Large Amount of Info
Climate Action 199 201
Death Penalty 199 201
Gun Control 199 201
Immigration 199 201
Transgender Rights 199 201
Small Reflection Time Large Reflection Time
Climate Action 200 201
Death Penalty 200 201
Gun Control 200 201
Immigration 200 201
Transgender Rights 200 201