Attitude Scales - Descriptives
#Author: Alyssa Lim
#Title: PSYC3361 Verification Report
#Date: 25/06/2024
#load 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
#load data
mainstudy <- read_csv("beliefsuperiority_all.csv")
## New names:
## Rows: 1454 Columns: 65
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (2): Q58, rid dbl (62): Q62...1, immigration_a, immigration_b, abortion_a,
## abortion_b, vot... num (1): Q62...49
## ℹ 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.
## • `Q62` -> `Q62...1`
## • `Q62` -> `Q62...49`
# set up data -------------------------------------------------------------
#filter non-consent rows and failed attention checks
mainstudy <- mainstudy %>%
filter(Q62...1 == 1) %>%
filter (AC_a == 3) %>%
filter (AC_b == 5) %>%
select(-starts_with("AC")) #remove attention check items
# calculate mean and SD for issue-relevant attitudes ----------------------
#transform 4-pt attitude scales to 5-pt
#4-pt scales: vote (belief), torture (belief), affirmation (belief)
#(5-1) * (x-1) / (4-1) + 1
mainstudy$vote_a = recode(
mainstudy$vote_a,
'2=1; 3=2.3333; 4=3.6667; 5=5'
)
## Warning: Unreplaced values treated as NA as `.x` is not compatible.
## Please specify replacements exhaustively or supply `.default`.
mainstudy$torture_a = recode(
mainstudy$torture_a,
'2=1; 3=2.3333; 4=3.6667; 5=5'
)
## Warning: Unreplaced values treated as NA as `.x` is not compatible.
## Please specify replacements exhaustively or supply `.default`.
mainstudy$affirmaction_a = recode(
mainstudy$affirmaction_a,
'2=1; 3=2.3333; 4=3.6667; 5=5'
)
## Warning: Unreplaced values treated as NA as `.x` is not compatible.
## Please specify replacements exhaustively or supply `.default`.
#Convert recoded variables to numeric
#This was added later, for some reason it worked without this part in the script
#May or may not need this section
mainstudy$vote_a <- as.numeric(mainstudy$vote_a)
mainstudy$torture_a <- as.numeric(mainstudy$torture_a)
mainstudy$affirmaction_a <- as.numeric(mainstudy$affirmaction_a)
#Calculate an average attitude score per participant
attitude <- mainstudy %>%
select(ends_with('_a')) %>%
mutate(mean_attitude = rowMeans(select(., ends_with('_a')), na.rm = TRUE))
#Summarise the mean attitude score for the sample
summary <- attitude %>%
summarise(
m_attitude = mean(mean_attitude),
stdev_attitude = sd(mean_attitude)
)
print(summary)
## # A tibble: 1 × 2
## m_attitude stdev_attitude
## <dbl> <dbl>
## 1 2.85 0.774