Challenge - 5 Problems
Box and Violin Plot Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of a basic boxplot in R
What will be the output of this R code snippet?
R Programming
data <- c(5, 7, 8, 5, 6, 9, 10, 12, 7, 6) boxplot(data, main = "Simple Boxplot")
Attempts:
2 left
💡 Hint
Boxplots summarize data distribution with median and quartiles.
✗ Incorrect
The boxplot function in R creates a box showing the median and quartiles. The whiskers extend to the min and max within 1.5 times the interquartile range. The data vector is valid input.
🧠 Conceptual
intermediate2:00remaining
Difference between boxplot and violin plot
Which statement correctly describes the difference between a boxplot and a violin plot?
Attempts:
2 left
💡 Hint
Think about what each plot reveals about the data.
✗ Incorrect
Boxplots summarize data with median, quartiles, and outliers. Violin plots add a smooth shape showing the full distribution density.
🔧 Debug
advanced2:00remaining
Identify the error in violin plot code
What error will this R code produce?
R Programming
library(ggplot2) data <- data.frame(group = rep(c('A', 'B'), each = 10), value = c(rnorm(10), rnorm(10, 2))) ggplot(data, aes(x = group, y = value)) + geom_violin() + geom_boxplot()
Attempts:
2 left
💡 Hint
Check if the code syntax and library usage are correct.
✗ Incorrect
The code loads ggplot2, creates a data frame with groups and values, then plots violin and boxplot layers. This is valid and runs without error.
❓ Predict Output
advanced2:00remaining
Output of customized boxplot with notch
What does the following R code produce?
R Programming
set.seed(123) data <- rnorm(50) boxplot(data, notch = TRUE, col = "lightblue", main = "Notched Boxplot")
Attempts:
2 left
💡 Hint
Notches show confidence intervals around the median.
✗ Incorrect
The notch parameter adds a notch shape around the median to indicate a confidence interval. The color changes the box fill.
❓ Predict Output
expert3:00remaining
Combined violin and boxplot with jittered points
What will be the output of this R code?
R Programming
library(ggplot2) set.seed(42) data <- data.frame(category = rep(c('X', 'Y'), each = 20), value = c(rnorm(20), rnorm(20, 1))) ggplot(data, aes(x = category, y = value)) + geom_violin(trim = FALSE, fill = "pink") + geom_boxplot(width = 0.1, fill = "white") + geom_jitter(width = 0.15, alpha = 0.5)
Attempts:
2 left
💡 Hint
Look at each geom layer and their parameters.
✗ Incorrect
The code creates a violin plot with tails shown (trim=FALSE), overlays a narrow white boxplot, and adds jittered points with some transparency.