Reply To: Eyetracking R script variations

PennController for IBEX Forums Support Eyetracking R script variations Reply To: Eyetracking R script variations

#10655
multanip
Participant

IF this is too confusing, I can send through email.

read.pcibex <- function(filepath, auto.colnames=TRUE, fun.col=function(col,cols){cols[cols==col]<-paste(col,"Ibex",sep=".");return(cols)}) {
  n.cols <- max(count.fields(filepath,sep=",",quote=NULL),na.rm=TRUE)
  if (auto.colnames){
    cols <- c()
    con <- file(filepath, "r")
    while ( TRUE ) {
      line <- readLines(con, n = 1, warn=FALSE)
      if ( length(line) == 0) {
        break
      }
      m <- regmatches(line,regexec("^# (\\d+)\\. (.+)\\.$",line))[[1]]
      if (length(m) == 3) {
        index <- as.numeric(m[2])
        value <- m[3]
        if (is.function(fun.col)){
          cols <- fun.col(value,cols)
        }
        cols[index] <- value
        if (index == n.cols){
          break
        }
      }
    }
    close(con)
    return(read.csv(filepath, comment.char="#", header=FALSE, col.names=cols))
  }
  else{
    return(read.csv(filepath, comment.char="#", header=FALSE, col.names=seq(1:n.cols)))
  }
}
require("dplyr")
require("ggplot2")
require("tidyr")
# The URL where the data is stored; note the ?experiment= at the end
ETURL = "https://psyli-lab.research-zas.de/eye-tracking_full_ger/eye-tracking_full_ger_results/php_full_ger.php?experiment="
# Time-window to bin the looks
BIN_DURATION = 100
# We'll use Reception time to identify individual sessions
results <- read.pcibex("~/Results online study/full_ger_pcibex_june/results.csv")
names(results)[1] <- 'Participant'
#write.csv(results, file = 'results_clean_RStudio2.csv',
         # row.names = FALSE)
# Read ET data file for each session and append output to ETdata (first 5 rows are corrupt)
ETdata = data.frame()
filesDF_bak <- subset(results, Parameter=="Filename"&displayID=="p10a") #tried to change the display ID to setnence but still showed p10a displayID for all
filesDF <- filesDF_bak[6:nrow(filesDF_bak),] 
apply(filesDF, 1, function(row) {
  data <- read.csv(paste(ETURL,as.character(row[['Value']]),sep=''))
  data$Participant <- row[['Participant']]
  data$displayID <- row[['displayID']] ##added this later and it showed the display id but only p10a for all
  datacheck <<- data
  ETdata <<- rbind(ETdata,data)
})
  • This reply was modified 10 months, 4 weeks ago by multanip.
  • This reply was modified 10 months, 4 weeks ago by multanip.
  • This reply was modified 10 months, 4 weeks ago by multanip.