library(grid) library(ggplot2) library(dplyr) library(likert) library(here) here() c = read.csv("logs/all_logs_final.csv", sep=",") c$Action_code <- factor(c$Action_code) levels(c$Action_code) <- list(VS1="SEL_SubC_CF", VS2="SEL_SubC_CM", VS3="SEL_SubC_CL", VS4="SEL_SubC_SL", VS5="SEL_SubC_SM", VS6="SEL_SubC_SR", VS7="SEL_SubC_G", VM1="MAN_M_SC", VM2="MAN_D_SubC", VM3="MAN_C_S", GS1="SEL_SupC_C", GS2="SEL_SupC_R", GS3="SEL_SupC_CS", GS4="SEL_SupC_CMC", GS5="SEL_SupC_CMNC", GS6="SEL_SupC_RS", GS7="SEL_SupC_RMC", GS8="SEL_SupC_RMNC", GS9="SEL_SupC_SVC", GS10="SEL_SupC_SVR", GM1="MAN_C_M", GM2="MAN_M_C", GM3="MAN_M_R", GM4="MAN_D_SupC", GM5="MAN_D_SupCC", GM6="MAN_D_SupCR", GM7="MAN_S_C", GM8="MAN_F_C") c$Gr <- substr(c$Action_code, 0, 2) library(ARTool) # Match score, effect of Action_code (referent) and pairwise comparisons mMatch = art(Match_score ~ Action_code + (1|Participant), data=c) anova(mMatch) comparisonsMatch <- art.con(mMatch, "Action_code", adjust="holm") %>% summary() %>% # add significance stars to the output mutate(sig. = symnum(p.value, corr=FALSE, na=FALSE, cutpoints = c(0, .001, .01, .05, .10, 1), symbols = c("***", "**", "*", ".", " "))) significantComparisonsMatch <- comparisonsMatch[comparisonsMatch$p.value<0.05, ] significantComparisonsMatch # Easy score, effect of Action_code (referent) and pairwise comparisons mEasy = art(Easy_score ~ Action_code + (1|Participant), data=c) anova(mEasy) comparisonsEasy <- art.con(mEasy, "Action_code", adjust="holm") %>% summary() %>% # add significance stars to the output mutate(sig. = symnum(p.value, corr=FALSE, na=FALSE, cutpoints = c(0, .001, .01, .05, .10, 1), symbols = c("***", "**", "*", ".", " "))) significantComparisonsEasy <- comparisonsEasy[comparisonsEasy$p.value<0.05, ] significantComparisonsEasy # plots rightorder = rev(c("VS1","VS2","VS3","VS4","VS5","VS6","VS7","VM1","VM2","VM3","GS1","GS2","GS3","GS4","GS5","GS6","GS7","GS8","GS9","GS10","GM1","GM2","GM3","GM4","GM5","GM6","GM7","GM8")) colorLabels <- "black" yOffset <- 90 likertPlot <- function(data,title) { likert.bar.plot(data, plot.percents=TRUE, plot.percent.low = FALSE, plot.percent.high = FALSE, plot.percent.neutral = FALSE) + # the line below doesn't work as I can't manage to have drawn in-between two successive levels of a categorical factor #geom_vline(xintercept = lkt$results$Group[lkt$results$Group == "GS10"] , color = colorLabels) + geom_vline(xintercept = 8.5, color = colorLabels, linetype="dotted", size = 1.5) + geom_vline(xintercept = 18.5, color = colorLabels, linetype="dotted", size = 1.5) + geom_vline(xintercept = 21.5, color = colorLabels, linetype="dotted", size = 1.5) + annotate("label", x = 4.25, y = -yOffset, label = "Grid Manipulations", colour = colorLabels, size = 6, hjust = 0) + annotate("label", x = 13.25, y = -yOffset, label = "Grid Selections", colour = colorLabels, size = 6, hjust = 0) + annotate("label", x = 20.25, y = -yOffset, label = "Value Manipulations", colour = colorLabels, size = 6, hjust = 0) + annotate("label", x = 25.25, y = -yOffset, label = "Value Selections", colour = colorLabels, size = 6, hjust = 0) + # scale_x_discrete(name ="Referent", limits = rightorder) + theme( panel.background = element_rect(fill = "white"), panel.grid.major = element_line(size = 0.05, linetype = 'solid', colour = "gray"), panel.grid.minor = element_line(size = 0.05, linetype = 'solid', colour = "gray"), text = element_text(size = 20), strip.text.x = element_blank() ) + theme(legend.title=element_blank()) + ggtitle(title) } c$Match_score <- ordered(c$Match_score, labels=c("Very poor match", "Poor match", "Neutral", "Good match", "Very good match")) lk = c lk[c(10)] <- lapply(lk[c(10)], factor, levels=c("Very poor match", "Poor match", "Neutral", "Good match", "Very good match")) lkt <- likert(lk[c(10)], grouping = lk$Action_code) likertPlot(lkt, "Match score") c$Easy_score <- ordered(c$Easy_score, labels=c("Not easy at all", "Not easy", "Neutral", "Easy", "Very easy")) lk = c lk[c(11)] <- lapply(lk[c(11)], factor, levels=c("Not easy at all", "Not easy", "Neutral", "Easy", "Very easy")) lkt <- likert(lk[c(11)], grouping = lk$Action_code) likertPlot(lkt, "Easy score")