Introduction

 

The purpose of this page is to provide you with enough information to be able to use the provided R-Scripts to process the data generated by the tasks available. the first section is simply some links to online resources that cover the basics that you need to be run the processing scripts provided.

Using R

 

This section is simply to provide the information required in order to use the scripts provided for analysing the output from the tasks and then to export the data to .csv format for analysis in whatever statistical package you choose.

Installation

 
I'm not going to insult users by going into detail on how to install a program on your machine. Visit the CRAN website and select the download approriate for your operating system.
 

Setting the working directory

 
Setting the Working Directory
 

Executing scripts

 
The following link provides an overview of running scripts in R; covering how to use the source() command to run a script entirely, or how to open the script within R and execute parts of code.
 

Exporting data

 
Writing data frames to CSV files

Running the scripts

 

For each task I provide two R scripts which you can run that will process the raw data from a task and produce a data matrix that is suitable for the majority of analysis techniques people are likely to want to use. The R script you should use depends on whether you have collected data using a single user account and intend to differentiate participants using the given 5-digit participant code, or if you created a user account per participant and therefore have multiple data files (one per user). There a few instructions which are fundamental to running the data scripts which I will outline here. Any task specific instructions will be given on the data section of the respective task.

Single User Method

 

Preparation

 

You will only have one CSV file to export, this file will have all the data from every participant you tested. The script will take every unique participant code as a new participant and summarise the data for each. The only preparation you need to process this data is;

  1. Export the CSV file and ensure you know exactly where it is
  2. Open the provided R-script for the specific task you are processing the data for. The second from botton command will by default have "datafile.csv" as the argument in the function. This needs to be changed to point to your exported CSV file. Two options:
    • Simply change it to the name of your exported csv file e.g. "matrix_span_data.csv". Then set your working directory in R to be the location of the file.
    • Alternatively, specify an absolute file path to the target data file, for example "~/Users/Stone/Data/matrix_span_data.csv".

 

Executing the script

 

See the notes below regarding executing a script, except in the single user account it does not matter if the script is in the same folder as the data file.

 

Multiple User Method

 

Preparation

 

To use these scripts to process the data it is necessary to put all output files from the task into one folder. This folder should only contain the data files for that specific task. The scripts work by loading the files one by one, summarising the data in them, and then adding the data to a data frame iteratively before returning the end product (data frame with one row per participant). Therefore if it tries to do these operations on any file that isn't the particular task output it is going to cause errors.

Secondly, when you export the data for a participant from the application it will provide a CSV file that contains all the information for all trials that user has completed. This behaviour stems from the fact that tatool was developed from a cognitive training perspective and therefore has many features built in to keep track of data over multiple sessions. Most studies will tend to involve just one administration of each task. Therefore, you just need to be aware that if you have a participant who has completed more trials than you requested (for example, because they did three trials and then quit the program and you restarted it for them; in this situation you would have three trials in the log with the session.id being 1 and a full set of trials with the session.id of 2.

I have included a notification in the scripts to alert you when a file has multiple session IDs. When you run the script, if R has found any of the files to contain multiple session IDs then a message will be printed in the console alerting you to the filenames in question. The script operates as normal, analysing all the trials, it is merely a warning to you that this might be something you need to investigate.

 

Executing the script

 

Place the script anywhere on your computer except the folder that has your data files to analyse. After you set the working directory of R to be the folder where your data is (explained above) then all you need to do is run the script (also explained above, two methods).

The scripts work by using two functions each. One function is designed to take the raw data for a participant and return a vector of summary data. A second function uses this first function to loop through all the files in your working directory and produce a data frame from all these vectors with appropriate names. The participants user name (this could be an actual name, or more likely in most research situations you might simply use an ID number) is always used to identify the participant within the data frame. The fact that this is identical across tasks also makes it extremely easy to merge data from multiple tasks using R.