Hi developers,
I’m in the middle of running a combo online experiment and survey project, and I’m trying to write R code to wrangle the data for my student. I have run into a minor problem - when a participant does not answer a question (I’m not sure how this is happening given that all our survey questions are set to “required”, but anyway it has happened), the whole question field is omitted from the downloaded datafile. So if they haven’t answered, say, q3, their datafile has q1, q2, q4. This makes it tricky to loop through the files and append the results, since each row is now a different length depending on the missing data.
Could the next iteration of Pavlovia surveys please address this issue?
Thanks
Deborah.
In general data columns are only added when they have data. You could download the survey data file (which has all participants and therefore all columns where at least one participant answered) or use database saving in PsychoPy (which skips the individual CSV files and instead creates a downloadable CSV with all participants (from the point that database saving is turned on).
Hello @deborah.apthorp
The following R-Code should read the data.
library(tidyverse)
#generate list of all csv
my_files <- list.files(pattern = "\\.csv$")
# # add file names for later identification
names(my_files) <- my_files
# read each file separately
my_dfs <- lapply(my_files, read_csv)
# combine everything
df_combined <- bind_rows(my_dfs, .id = "df")
Best wishes Jens
Hi Jens,
I already tried bind_rows but it does not work if the rows have different numbers of columns.
Thanks
Deborah.