Make sure you follow the analysis protocol when analyzing lab data
All analyses in the lab should start with a header text (fill in the relevant information for your study), loading the libraries you need, and printing out your session information, so you remember what package versions you used, etc.
You'll have one .csv file of your data that you export from the lab's database. You can import it by uploading the file in google colab and using the
data <- read_csv('data-exp1.csv')
Sometimes you want to create different data frames for different phases of your experiment. You can do this with
production <- data %>% filter(exp_phase == 'production')raing <- data %>% filter(exp_phase == 'rating')
Usually you'll need to report (at least) how many participants were in your study, their gender, and their age. You can do this with group_by and summarise. In this example, we first group together by participant (because each participant has many trials), then we group together by condition and age_group.
data %>% group_by(condition, age_group, random_id, age, female) %>%summarise(n = n_distinct(random_id)) %>%group_by(condition, age_group) %>%summarise(n = n(), n_female = sum(female), mean_age = mean(age))
In many of our studies, we want to know how often (proportion) a participant used a particular marker in the production test out of correct nouns. First we can get the number of trials with correct nouns and merge it back with the filtered correct noun production data.
production %>% filter(corr_noun == TRUE) %>% group_by(random_id) %>%summarise(n_trials = n()) %>%left_join(filter(production, corr_noun == TRUE), by = "random_id")
Then we can get