#################################################################################### # # LEARNING TIME PER TASK # #################################################################################### library(plyr) library(stringr) #source("CI-Functions.R") source("CI-Functions-Bonferroni.R") defaultpath <- dirname(rstudioapi::getActiveDocumentContext()$path) setwd(defaultpath) file <-"./data/user_answers_ms.csv" tmp <- read.csv(file, stringsAsFactors=FALSE) tmp <- tmp [ which (dataFile$Marked == 0 ),] tmp$error <- tmp$is_correct tmp$error[tmp$is_correct == "False"] <- 1 tmp$error[tmp$is_correct == "True"] <- 0 tmp$error <- as.numeric(as.character(tmp$error)) mydata <- aggregated_table <- ddply(tmp, c("user","vis", "question_code", "question_internal_id", "is_training" ), summarise, mean_error = mean(error)*100, # turn [0,1] values to percentages mean_time = mean(time) / 1000, # turn milliseconds to seconds mean_confidence = mean(confidence), mean_difficulty = mean(difficulty) ) mydata$question_code <- gsub("C", "CO", mydata$question_code) mydata$question_code <- gsub("A", "CO", mydata$question_code) mydata$question_code <- gsub("B", "CO", mydata$question_code) mydata$question_code <- gsub("D", "MA", mydata$question_code) mydata$question_code <- gsub("E", "MA", mydata$question_code) mydata$question_code <- gsub("F", "MA", mydata$question_code) mydata$question_code <- gsub("I", "SI", mydata$question_code) mydata$question_code <- gsub("G", "SI", mydata$question_code) mydata$question_code <- gsub("H", "SI", mydata$question_code) mydata$question_code <- gsub("J", "CH", mydata$question_code) mydata$question_code <- gsub("K", "CH", mydata$question_code) mydata$question_code <- gsub("L", "CH", mydata$question_code) path = paste0("plots/4_per_task_learning/raw/") ############################# # analysis of all questions individually # ############################# #do the analysis per task tasks <- c("CO", "CH", "SI", "MA") vis_all <- c('storylines', "paohvis") #vis <- 'storylines' #current_task <- 'CO' for (vis in vis_all) { for (current_task in tasks) { print ("--------------------") print (paste("Current task: ", current_task)) elements <- mydata [ which (mydata$question_code == current_task & mydata$vis == vis),] # select only data for this task # order for the transpose elements <- elements [ order(elements$user, elements$is_training), ] # keep only columns needed myvars <- c("user", "is_training", "mean_time") elements <- elements [myvars] #aggregating all cases per participant (3 repetitions) statstable_time <- ddply(elements, c("user","is_training"), summarise, time=mean(mean_time) ) elements <- statstable_time # elements <- reshape(elements, timevar="is_training", idvar=c("user"), direction="wide") colnames(elements) <- c("user", "main", "training") # drop columns with N/A elements <- na.omit(elements) ######### # stats # ######### data <- elements techniqueA <- bootstrapMeanCI(data$training) techniqueB <- bootstrapMeanCI(data$main) analysisData <- c() analysisData$name <- c("Advanced","Exploratory") analysisData$pointEstimate <- c(techniqueB[1], techniqueA[1]) analysisData$ci.max <- c(techniqueB[3], techniqueA[3]) analysisData$ci.min <- c(techniqueB[2], techniqueA[2]) datatoprint <- data.frame(factor(analysisData$name),analysisData$pointEstimate, analysisData$ci.min, analysisData$ci.max) colnames(datatoprint) <- c("phase", "mean_time", "lowerBound_CI", "upperBound_CI ") #We use the name mean_error for the value of the mean even though it's not a time, it's just to parse the data for the plot filename = paste0("phase_time_means_task_",current_task,"_", vis) write.table(datatoprint, paste0(path, "printed_",filename,".txt",seq=""), sep=",",row.names=FALSE) # CIs with adapted alpha value for multiple comparisons diffBA = bootstrapMeanCI_corr(data$main - data$training, 1) analysisData <- c() analysisData$name <- c("Adv-Explo") analysisData$pointEstimate <- c(diffBA[1]) analysisData$ci.max <- c(diffBA[3]) analysisData$ci.min <- c(diffBA[2]) analysisData$level <- c(diffBA[4]) analysisData$ci_corr.max <- c(diffBA[6]) analysisData$ci_corr.min <- c(diffBA[5]) datatoprint <- data.frame(factor(analysisData$name), analysisData$pointEstimate, analysisData$ci.max, analysisData$ci.min, analysisData$level, analysisData$ci_corr.max, analysisData$ci_corr.min) colnames(datatoprint) <- c("phase", "mean_time", "lowerBound_CI", "upperBound_CI", "corrected_CI", "lowerBound_CI_corr", "upperBound_CI_corr") #We use the name mean_error for the value of the mean even though it's not a time, it's just to parse the data for the plot filename = paste0("phase_time_diffs_task_",current_task, "_", vis) write.table(datatoprint, paste0(path,"printed_",filename,".txt",seq=""), sep=",",row.names=FALSE) } # end of loop for each task }