library(plyr) library(dplyr) library(MPDiR) library(quickpsy) library(fitdistrplus) library(ggplot2) # Global values for our conditions speed_duration <- c('30-fast-irregular-movement','30-fast-linear-movement','15-slow-irregular-movement', '15-slow-linear-movement') correct_answer <- c(18,32,43,0,58,72,83) # set directory where script is sourceDir <- dirname (rstudioapi::getActiveDocumentContext()$path) defaultpath <- sourceDir #remove(list = ls()) print(defaultpath) setwd(defaultpath) # get all log files setwd("exp-data/") file_list <- list.files(pattern=".csv") show(file_list) if (exists ("allData")) { rm(allData) } # basic loop that reads over participant files # and computes normalized errors for (file in file_list){ print(file) dataFile <- read.csv(file) # collect all trials in order to calculate error rate, keep non training trials (trial > 0) tmp <- dataFile # tmp <- tmp [ which (tmp$study_id != 'Pilot'),] # not Pilot study_id ADD BACK FOR EXPERIMENT tmp <- tmp [ which (tmp$correct_answer != 0),] #no trial 0 tmp$abs_error <- abs(tmp$given_answer-tmp$correct_answer) #absolute error tmp$true_error <- (tmp$given_answer-tmp$correct_answer) #true error if ( !exists("allData") ){ allData <- tmp } else { allData <- rbind(allData,tmp) } } print(defaultpath) setwd(defaultpath) write.csv(allData, file="results/all_data.csv")