To better understand how A/B testing works, we will generate example data to demonstrate statistical analysis.
- Version A and Version B represent two UI designs.
- Each user attempts tasks and their outcomes are recorded as:
- Task success (1 = success, 0 = failure)
- Time taken to complete the task
The following R code generates example data for analysis:
# Create groups representing versions A and B (10 of each)
group = c(rep("A", 10), rep("B", 10))
# Maintain the randomly produced values below over each run of code
set.seed(123)
# Create 20 random task success values (0 and 1)
success = sample(c(0, 1), size = 20, replace = TRUE)
# Create 20 random time spent on task values (in seconds)
time = sample(c(5:25), size = 20, replace = TRUE)
# Combine into dataset
data = data.frame(group, success, time)