if(!require(psych)){install.packages("psych")} if(!require(likert)){install.packages("likert")} defaultpath <- dirname(rstudioapi::getActiveDocumentContext()$path) setwd(defaultpath) file <-"user_answers_ms.csv" mydata <- read.table(file, header=T, sep=",") # collect all trials in order to calculate average error rate and time per question per participant, keep non training trials (isTraining = "False") tmp <- dataFile tmp <- dataFile [ which (dataFile$is_training == "False"),] # keep trials that are not training #do the analysis per task tasks <- c("B","C","D","E","F","G","H","I") for (current_task in tasks) { print ("--------------------") print (paste("Current task: ", current_task)) tmp <- dataFile [ which (dataFile$question_code == current_task),] tmp <- tmp [ order(tmp$user, tmp$vis), ] # myvars <- c("user", "vis", "question_code","question_internal_id","confidence") tmp <- tmp [myvars] tmp2 <- reshape(tmp, timevar="vis", idvar=c("user","question_code","question_internal_id"), direction="wide") colnames(tmp2) <- gsub("confidence.", "", colnames(tmp2)) tmp2 <- na.omit(tmp2) likert_table <- tmp2 myvars <- c("Barchart", "Dorling","Symbol") # Symbol name has been changed in paper to Glyph likert_table <- likert_table[myvars] likert_table$Barchart = factor (likert_table$Barchart, levels = c("1","2","3"), ordered = TRUE) likert_table$Dorling = factor (likert_table$Dorling, levels = c("1","2","3"), ordered = TRUE) likert_table$Symbol = factor (likert_table$Symbol, levels = c("1","2","3"), ordered = TRUE) # tasks <- c("B","C","D","E","F","G","H","I") library(psych) headTail(likert_table) str(likert_table) library(likert) Result <- likert(likert_table) summary(Result) plot(Result, type="bar") # warning, the ordering of techniques changes - need to reorder later path = paste("plots/") filename = paste0("conf_task_",current_task) ggsave(paste0(path,"plot_",filename,".pdf",seq=""),device = pdf, width=8, height=2) }