R Script

this page assumes that you are already familiar with R

Starting with a clean slate

You probably tested your experiments at multiple steps along the way, at which your were recording different pieces of information in the results file. Now that you have a final design, scroll down to results and click delete next to your files results and raw_results.

Then take your experiment at least twice, entering different IDs, to generate some results. Click refresh to see the new results files appear under results.

Save your results file in a folder that you will be able to access from an R script.

Load your results file in R

Add the function below to your R script so you can read your results file in R as a CSV file, and automatically name the columns using the comments lines:

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=","),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) {
      m <- regmatches(line,regexec("^# (\\d+)\\. (.+)\\.$",line))[[1]]
      if (length(m) == 3) {
        index <- as.numeric(m[2])
        value <- m[3]
        if (index < length(cols)){
          cols <- c()
        if (is.function(fun.col)){
         cols <- fun.col(value,cols)
        cols[index] <- value
        if (index == n.cols){
    return(read.csv(filepath, comment.char="#", header=FALSE, col.names=cols))
    return(read.csv(filepath, comment.char="#", header=FALSE, col.names=seq(1:n.cols)))

Then all you need to do to read your results file is results <- read.pcibex("results") (assuming your saved your results file in your R working directory under the name results).

You can then take a look at the first lines of your table, and their column names, using head(results).

By default, when it finds more than one column given the same description in the comments of the results file, the function above suffixes the first column name with .Ibex. Since the native IBEX format already inserts two columns in the results file described as Item and Group, and since if you used .log( "Item" , variable.Item ) and .log( "Group" , variable.Group ) on your table-generated trials, this behavior ensures that the Ibex-native columns (which appear first) are named Item.Ibex and Group.Ibex while the columns you added using the .log commands are indeed named Item and Group.

Compare RTs

You can easily take a look at response times using the dplyr package:


results %>%
  filter(Ending %in% c("1st","3rd") & (Parameter == "Selection" | Value == "Start")) %>%
  mutate( Accurate = rep(Value[Parameter=="Selection"]==gsub("1st","one", gsub("3rd", "two", Ending[Parameter=="Selection"])), each=2)) %>%
  group_by(Accurate, Ending, Group, ID) %>%
  summarise( RT = mean(EventTime[Parameter=="Selection"] - EventTime[Value=="Start"]) , N = length(Value)/2 )

Our filter excludes rows which do not report 1st or 3rd (the welcome-trial rows) and keeps only those corresponding to a selection or to the start of a trial.

The function mutate adds a column Accurate indicating whether the Value for the Selection rows matches its Ending.

We then group our rows by Accurate and Ending to get a clear idea of the effect of our manipulation (presence vs absence of -s) and also by Group and ID to get individual observations.

Finally we report the mean differences between the EventTime of the Selection minus the Start rows, along with the number of observations (two rows per trial, Start and Selection, call for a division by 2).