-
Notifications
You must be signed in to change notification settings - Fork 0
/
clean_qualtrics_export.Rmd
91 lines (67 loc) · 3.13 KB
/
clean_qualtrics_export.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
---
title: "Clean Qualtrics Export"
author: "Ari Dyckovsky"
output:
md_document:
variant: markdown_github
---
# Clean Qualtrics Export
```{r, setup, include=FALSE}
knitr::opts_chunk$set(
warning = FALSE,
strip.white = TRUE,
tidy = TRUE,
highlight = TRUE
)
```
## Load packages
```{r, package-loading, message=FALSE}
library(dplyr)
library(purrr)
library(tidyr)
library(ggplot2)
library(hash)
```
## Constants
```{r, constants}
QUALTRICS_FILENAME = "qualtrics.tsv"
```
## Set datapath and load `shlab.imgct`
Begin by setting the working directory and important top-level paths to data and
loading necessary packages.
- NOTE: This will be changed to dynamically account for the package `shlab.imgct` via
its GitHub instance later. For now, it is using development loading.
```{r, shlab-setup, message=FALSE}
# Set the working directory to be part of S Drive (may make dynamic later?)
# Whilst not dynamic, change for own session if mount point is not equivalent on
# local machine
shared_dir <- "~/Projects/shlab/mounts/imgct"
package_dir <- "~/Projects/shlab"
datapath <- file.path(shared_dir, "csn_images")
imgct_package_path <- file.path(package_dir, "shlab.imgct")
# Make sure that devtools, tidyverse are installed before this call
devtools::load_all(imgct_package_path)
```
## Load Qualtrics TSV
Using the convience method `shlab.imgct::load_qualtrics_tsv` will load a TSV export of Qualtrics response data collected from the image categorization task. (Please note that the output of this raw dataset is hidden to maintain participant privacy.)
```{r, load-raw-data}
qualtrics_export <- shlab.imgct::load_qualtrics_tsv(datapath)
```
## Parse Qualtrics Export
Remove unnecessary columns of data from the Qualtrics exported data, and remove participant rows in which the task was not complete. The output of this function will show the first five participants.
```{r, parse-qualtrics. results='asis'}
qualtrics_export_parsed <- shlab.imgct::parse_qualtrics_export(qualtrics_export)
knitr::kable(head(
qualtrics_export_parsed, # the table to visualize
5))
```
## Clean Qualtrics Export
The two above demonstrations are included within the function to clean Qualtrics exported survey data for this task. Additionally, the `clean` function is a convenience on top of `clean_qualtrics_export` that (currently) only allows for Qualtrics TSV response data. Within the call, TXT files of each image block are loaded to rename columns for each block of image categorization rating responses, as Qualtrics also unfortunately replaces columns with each block of images surveyed.
```{r, clean-qualtrics-export, eval=FALSE}
# Here, we demonstrate the underlying Qualtrics-specific method
shlab.imgct::clean_qualtrics_export(datapath, filename = QUALTRICS_FILENAME)
```
Using the convenient abstraction `clean`, we can load, parse, and clean each block of image categorization rating responses across participants. This will, notably, remove any participant that that has errors in their responses, too. If successful, the cleaned blocks will be saved to the `~/datapath/clean` directory.
```{r, clean-qualtrics}
shlab.imgct::clean(datapath, filename = QUALTRICS_FILENAME)
```