#################################################################################### # # times # #################################################################################### library(plyr) #source("CI-Functions.R") source("CI-Functions-Bonferroni.R") defaultpath <- dirname(rstudioapi::getActiveDocumentContext()$path) setwd(defaultpath) path <- 'plots/all_tasks/raw/' # Select phase to analyze phase <- '_main' file_data <- paste0("aggregated_data", phase,".csv") if (exists ("mydata")) { rm(mydata) } mydata <- read.table(file_data, header=T, sep=",") ############################# # analysis of all questions # ############################# # order for the transpose elements <- mydata elements <- elements [ order(elements$user, elements$vis), ] # myvars <- c("user", "vis", "mean_time") elements <- elements [myvars] #aggregating all cases per participant statstable_time <- ddply(elements, c("user","vis"), summarise, time=mean(mean_time) ) elements <- statstable_time # elements <- reshape(elements, timevar="vis", idvar=c("user"), direction="wide") colnames(elements) <- gsub("time.", "", colnames(elements)) # drop columns with N/A elements <- na.omit(elements) ######### # stats # ######### data <- elements if (mean (data$GlyMa) == 0 ) { techniqueA <- c(0.000000,0.000000,0.000000) } else { techniqueA <- bootstrapMeanCI(data$GlyMa) } if (mean (data$CoordV) == 0 ) { techniqueB <- c(0.000000,0.000000,0.000000) } else { techniqueB <- bootstrapMeanCI(data$CoordV) } if (mean (data$LocSto) == 0 ) { techniqueC <- c(0.000000,0.000000,0.000000) } else { techniqueC <- bootstrapMeanCI(data$LocSto) } # # Calculating means per condition # analysisData <- c() analysisData$name <- c("TimeG","CoordV", "MapG") analysisData$pointEstimate <- c(techniqueC[1], techniqueB[1], techniqueA[1]) analysisData$ci.max <- c(techniqueC[3], techniqueB[3], techniqueA[3]) analysisData$ci.min <- c(techniqueC[2], techniqueB[2], techniqueA[2]) datatoprint <- data.frame(factor(analysisData$name),analysisData$pointEstimate, analysisData$ci.min, analysisData$ci.max) colnames(datatoprint) <- c("vis", "mean_time", "lowerBound_CI", "upperBound_CI ") #We use the name mean_time 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("time_means_task_all", phase) write.table(datatoprint, paste0(path,"printed_",filename,".txt",seq=""), sep=",",row.names=FALSE) # # Calculating differences of means # # CIs with adapted alpha value for multiple comparisons not needed here if (mean(data$CoordV) == 0 & mean(data$GlyMa) == 0) { diffBA <- c(0.000000,0.000000,0.000000,1,0.000000,0.000000) } else { diffBA = bootstrapMeanCI_corr(data$CoordV - data$GlyMa, 1) } if (mean(data$LocSto) == 0 & mean(data$GlyMa) == 0) { diffCA <- c(0.000000,0.000000,0.000000,1,0.000000,0.000000) } else { diffCA = bootstrapMeanCI_corr(data$LocSto - data$GlyMa, 1) } if (mean(data$LocSto) == 0 & mean(data$CoordV) == 0) { diffCB <- c(0.000000,0.000000,0.000000,1,0.000000,0.000000) } else { diffCB = bootstrapMeanCI_corr(data$LocSto - data$CoordV, 1) } analysisData <- c() analysisData$name <- c("TimeG-CoordV","Time-MapG","CoordV-MapG") analysisData$pointEstimate <- c(diffCB[1], diffCA[1], diffBA[1]) analysisData$ci.max <- c(diffCB[3], diffCA[3], diffBA[3]) analysisData$ci.min <- c(diffCB[2], diffCA[2], diffBA[2]) analysisData$level <- c(diffCB[4], diffCA[4], diffBA[4]) analysisData$ci_corr.max <- c(diffCB[6], diffCA[6], diffBA[6]) analysisData$ci_corr.min <- c(diffCB[5], diffCA[5], 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("technique", "mean_time", "lowerBound_CI", "upperBound_CI", "corrected_CI", "lowerBound_CI_corr", "upperBound_CI_corr") #We use the name mean_time 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("time_diffs_task_all", phase) write.table(datatoprint, paste0(path,"printed_",filename,".txt",seq=""), sep=",",row.names=FALSE)