show code
<- read.csv('Data/ACR1.csv') %>%
study1a_raw mutate(attCheck = rowMeans(select(.,"AC.male.1.SocialDist__attCheck", "AC.male.2.SocialDist__attCheck",
"C.male.1.SocialDist__attCheck", "C.male.2.SocialDist__attCheck",
"AC.fmale.1.SocialDist__attCheck", "AC.fmale.2.SocialDist__attCheck",
"C.fmale.1.SocialDist__attCheck", "C.fmale.2.SocialDist__attCheck"), na.rm=TRUE)) %>%
filter(Progress==100)
= study1a_raw %>%
study1a filter(attCheck == 7 & grepl('orange', study1a_raw$bot.check1_4_TEXT, ignore.case=TRUE)) %>%
mutate(ID = 1:nrow(.), #assign ID
across(matches(".dishonest"), ~ 8 - .), #reverse code dishonest & reoffend
across(matches(".reoffend"), ~ 8 - .)) %>%
mutate(AC.trust = rowMeans(select(., matches("^A.*trust")), na.rm=TRUE) -1, #collapse trustworthy variable across stimuli and change from 1-7 to 0-6 scale
C.trust = rowMeans(select(., matches("^C.*trust")), na.rm=TRUE) -1,
AC.dishonest = rowMeans(select(.,matches("^A.*dishonest")), na.rm=TRUE) -1, #collapse dishonest variable and change from 1-7 to 0-6 scale
C.dishonest = rowMeans(select(.,matches("^C.*dishonest")), na.rm=TRUE) -1,
AC.remorse = rowMeans(select(.,matches("^A.*remorse")), na.rm=TRUE) -1, #collapse remorse variable and change from 1-7 to 0-6 scale
C.remorse = rowMeans(select(.,matches("^C.*remorse")), na.rm=TRUE) -1,
AC.secondChance = rowMeans(select(.,matches("^A.*secChance")), na.rm=TRUE) -1, #collapse second chance variable and change from 1-7 to 0-6 scale
C.secondChance = rowMeans(select(.,matches("^C.*secChance")), na.rm=TRUE) -1,
AC.reoffend = rowMeans(select(.,matches("^A.*reoffend")), na.rm=TRUE) -1, #collapse reoffend variable and change from 1-7 to 0-6 scale
C.reoffend = rowMeans(select(.,matches("^C.*reoffend")), na.rm=TRUE) -1,
AC.better = rowMeans(select(.,matches("^A.*better")), na.rm=TRUE) -1, #collapse better variable and change from 1-7 to 0-6 scale
C.better = rowMeans(select(.,matches("^C.*better")), na.rm=TRUE) -1,
AC.changeBett = rowMeans(select(.,matches("^A.*changeBett")), na.rm=TRUE) -1, #collapse changed for the better better variable and change from 1-7 to 0-6 scale
C.changeBett = rowMeans(select(.,matches("^C.*changeBett")), na.rm=TRUE) -1)
#calculate alpha for DV items before reducing columns & collapsing items. Note this calculates alpha only using the responses in the appearance change condition because it is within subjects design
= round(psych::alpha(select(study1a ,matches("AC.dishonest"), matches("AC.trust"), matches("AC.remorse"), matches("AC.secChance"), matches("AC.reoffend"), matches("AC.better"), matches("AC.changeBett")))$total[1,1], 2)
study1a_alpha
= study1a %>%
study1a select(c('gender','age','race',tail(names(.), 15))) %>% #select only demographics, ID & DV items
mutate(AC.redemption = rowMeans(select(.,matches("^AC.*")), na.rm=TRUE), #collapse all DV items to one redemption variable
C.redemption = rowMeans(select(.,matches("^C.*")), na.rm=TRUE))
= study1a %>%
study1a_long pivot_longer(5:20,
names_to = c("condition","trait"),
names_pattern="([^.]+.)(.*)") %>%
spread(trait, value) %>%
mutate(condition = factor(condition, levels=c('C.','AC.'), labels=c('control','appearanceChange')))