Back
Close

Computing with Data

elgeish
33.2K views

Box Plots

Histograms are very useful for summarizing numeric data in that they show a rough distribution of values. An alternative that is often used in conjunction with histograms is box plots. A box plot is composed of a box, an inner line bisecting the box, whiskers that extend to either side of the box, and outliers:

# Display 0 through 100 percentiles at 0.1 increments
# for the dataset containing 1, 2, 3, 4.
quantile(c(1, 2, 3, 4), seq(0, 1, length.out = 11))
ggplot(mpg, aes("", hwy)) +
geom_boxplot() +
coord_flip() +
scale_x_discrete("") +
ggtitle("Highway MPG")
# Plot several box plots side-by-side in order to compare data
# corresponding to different values of a factor variable
ggplot(mpg, aes(reorder(class, -hwy, median), hwy)) +
geom_boxplot() +
coord_flip() +
scale_x_discrete("class") +
ggtitle("Highway MPG by Class")
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants