Skip to main content
Version: v2.4.4

Example Data Analysis

Below is an example of how to analyze the data collected from the Brush Interactions Demo study using R. The data is available in a tidy format, which makes it easy to manipulate and visualize.

1. Install Necessary Packages​

list.of.packages <- c("ggplot2", "Hmisc")
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)

library(ggplot2)

2. Read and Preview the Data​

df <- read.csv("data/example-brush-interactions_all_tidy.csv")
head(df)

Here is a (truncated) preview of the data:

participantIdtrialIdtrialOrderresponseIdstageanswercorrectAnswerduration
b3d13c52rectangleBrush_q13responseDEFAULT181716660
b3d13c52axisBrush_q24max-responseDEFAULTsunsun22369
b3d13c52axisBrush_q24min-responseDEFAULTdrizzledrizzle22369
b3d13c52sliderBrush_q25max-responseDEFAULTGentooGentoo16142
b3d13c52sliderBrush_q25min-responseDEFAULTChinstrapAdelie16142
b3d13c52rectangleBrush_q26max-responseDEFAULTJapanJapan25142
b3d13c52rectangleBrush_q26min-responseDEFAULTEuropeEurope25142

This is data for one participant. The trialId column indicates the task, answer shows the participant's answer, and correctAnswer shows the correct response, etc. For example, condition sliderBrush_q2 has two responses: a min-response and a max-response.

3. Filter Data for Task q2 and Evaluate Correctness​

Now, we want to only look at data for task q2 and check if the participant's answer is correct.

q2 <- subset(df, grepl("_q2", trialId) & status == "completed")



We can create a new column `isCorrect` that indicates whether the answer matches the correct answer.

```r
q2 <- subset(df, grepl("_q2", trialId) & status == "completed")
q2$isCorrect <- ifelse(q2$answer == q2$correctAnswer, 1, 0)

4. Create a Violin Plot​

The plot displays correct answers on the right and incorrect answers on the left.

ggplot(q2, aes(x = isCorrect, y = trialId)) +
geom_violin(aes(fill = trialId), color = "#888", alpha = 0.7) +
stat_summary(fun.data = "mean_cl_boot", colour = "#333", size = 0.5, alpha=0.5) +
theme_minimal() +
theme(legend.position = "none") +
labs(
title = "Violin Plot for q2 (Finding most/least value)",
)

Violin Plot

We find accuracy using paint brush technique is much less than that of the others.

5. Export the generated plot.​

ggsave("plot.pdf", width = 5, height = 2, units = "in")