if(!require(psych)){install.packages("psych")} if(!require(likert)){install.packages("likert")} library(data.table) defaultpath <- dirname(rstudioapi::getActiveDocumentContext()$path) setwd(defaultpath) if (exists ("mydata")) { rm(mydata) } mydata <- read.table("aggregated_data.csv", 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 <- mydata tmp <- tmp [ order(tmp$user, tmp$vis), ] #do the analysis per task tasks <- c("A", "B","C","D","E") for (current_task in tasks) { print ("--------------------") print (paste("Current task: ", current_task)) tmp <- mydata [ which (mydata$question_code == current_task),] tmp <- tmp [ order(tmp$user, tmp$vis), ] # myvars <- c("user", "vis", "question_code","question_internal_id","mean_confidence") tmp <- tmp [myvars] tmp2 <- reshape(tmp, timevar="vis", idvar=c("user","question_code","question_internal_id"), direction="wide") colnames(tmp2) <- gsub("mean_confidence.", "", colnames(tmp2)) tmp2 <- na.omit(tmp2) setnames(tmp2, old=c("SmallMultiples","Animation", "OneMap"), new=c("SMul","Ani", "Gly")) likert_table <- tmp2 myvars <- c("SMul", "Ani","Gly") # Symbol name has been changed in paper to Glyph likert_table <- likert_table[myvars] likert_table$SMul = factor (likert_table$SMul, levels = c("1","2","3"), ordered = TRUE) likert_table$Ani = factor (likert_table$Ani, levels = c("1","2","3"), ordered = TRUE) likert_table$Gly = factor (likert_table$Gly, levels = c("1","2","3"), ordered = TRUE) library(psych) headTail(likert_table) str(likert_table) library(likert) Result <- likert(likert_table) summary(Result) plot(Result, type="bar", group.order=c("SMul", "Ani", "Gly")) # 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) }