Skip to content

Instantly share code, notes, and snippets.

@benmarwick
Created October 24, 2024 04:17
Show Gist options
  • Save benmarwick/da75e66d8a8e989ba0ff4f19e58c54e4 to your computer and use it in GitHub Desktop.
Save benmarwick/da75e66d8a8e989ba0ff4f19e58c54e4 to your computer and use it in GitHub Desktop.
what is the correct boxplot for this histogram?
data <- tibble( x = c(
# Peak 1 (around 0-2)
rep(1, 50), rep(2, 30), rep(3, 20),
# Dip (middle values)
rep(4, 10), rep(5, 8), rep(6, 8), rep(7, 10),
# Peak 2 (around 10-12)
rep(8, 20), rep(9, 30), rep(10, 50)
))
ggplot(data) +
aes(x) +
geom_histogram(bins = 10)
ggplot(data) +
aes(x) +
geom_boxplot()
@benmarwick
Copy link
Author

Here's the question:

image

Here's the histogram I can make to reproduce the question:

image

Here's the boxplot of the same data:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment