Analysis protocol

Protocol for data analysis

Prerequisites

  • None! But see FAQs below for some tips and advice.

Step 1: Download data

Download your data from the lab's database by entering your Experiment ID number on the View Runs tab. You can find your ID number on the Experiments tab.

Download your data from the View Runs tab

Step 2: Open the lab's RStudio Cloud

If you're an undergrad working with Katie on a project, use this method!

We analyze data in our RStudio Cloud . If you are a grad student, post-doc, or friend of the lab, AND you prefer to analyze on your local machine, skip to Step 3

Login with github

Login to the R Studio Cloud with GitHub — this is important to allow you access to shared code. You can ping Katie in basecamp to request an access link to the lab's cloud.

Login with GitHub!

Open your R project

Open your project in the RStudio Cloud

Configure git in RStudio Cloud

Once inside the project, configure git by entering the following commands in the terminal, replacing you@example.com with your email address and Your Name with your own name.

git config --global user.email "you@example.com"
git config --global user.name "Your Name"

This helps us keep track of who made what changes to the code in the github repo.

Pull any recent changes

Since these are collaborative projects, you'll want to pull in any changes your collaborator has made. Navigate to the git tab and click the blue down arrow (next to Commit) to do so.

Blue down arrow in the Git tab pulls in changes

Upload data

Next you'll want to upload the .csv file you exported in step 1. Click the data folder, then upload, then choose file.

Upload your data into your project's data folder

Step 3: Clean data

Parse JSON data

In the .csv file, each row is a run of the experiment. The data column includes the JSON data (from jsPsych) for that run. Usually you'll want to make each trial in the JSON it's own row — you can do this using the tidyjson library in R.

# load required libraries
library(tidyverse)
library(tidyjson)
# read in your data file
data <- read.csv("data/name-of-your-data-file.csv") %>%
# expand the json so each trial is a row
as.tbl_json(json.column="data") %>% gather_array %>% spread_all

Remove tester data

We use participant_id 0 to indicate test runs of the experiment. When testing on prolific (via their preview feature), prolific grabs our lab's prolific ID 5cc08aa4d923cf0016ea55a5. Remove this data by adding a filter, as in line 6 below.

If you are a friend of the lab using a different prolific account, you'll need to use your home lab's prolific ID here.

# read in your data file
data <- read.csv("data/name-of-your-data-file.csv") %>%
# expand the json so each trial is a row
as.tbl_json(json.column="data") %>% gather_array %>% spread_all %>%
# remove tester data, participant_id 0 and lab's prolific ID
filter(!(participant_id %in% c(0, "5cc08aa4d923cf0016ea55a5")))

Step 4: Analyze

Now you are free to analyze however you like!

Coming soon: How to do common lab analyses.

Step 6: Commit and push changes

To allow us to work collaboratively on the code, you'll need to push your changes to the GitHub repository. There are 3 steps:

  1. Save your changes

  2. Navigate to the Git tab and stage the files you edited and saved

  3. Commit those files and push them to the repo

Save your changes

The git tab shows the files you've changed and saved

Stage the files

Click the boxes under 'Staged' to stage the files, then click the commit button

Commit and push changes

This screen pops up when you click the 'commit' button Enter a commit message
Then press push; you'll like be asked for your github credentials

FAQs

How do I get access to the lab's RStudio Cloud?

Send a message to Katie or Ariel in basecamp to request access.

Can I use my local RStudio to analyze?

Yes if you are a grad student or postdoc! If you are an undergrad working with Katie, you need to use the lab's RStudio Cloud.

I don't see a project for my experiment in the lab's RStudio Cloud.

Either one doesn't exist or you don't have access to it. Send Katie a message in basecamp to request access.

I want to try some random stuff, but don't want to mess with my official project. Is there some place to do that in the lab's RStudio Cloud?

Yes! You want your personal Workspace. Click New Project to create an empty R Project and go nuts! Do whatever you want there — it's for you.

Your Workspace is yours to do whatever you want

I don't know how to program in R, any advice?

Yes! The lab's RStudio Cloud has tutorials built right in. Click Primers under Learn in the sidebar to access the tutorials. I recommend doing (1) The Basics, (2) Tidy your data, and (3) Visualize data in that order!