Graphics Reference
In-Depth Information
Figure 6-18. Box plot of a single group
NOTE
The calculation of quantiles works slightly differently from the
boxplot()
function in base R. This can
sometimes be noticeable for small sample sizes. See
?geom_boxplot
for detailed information about
how the calculations differ.
Adding Notches to a Box Plot
Problem
You want to add notches to a box plot to assess whether the medians are different.
Solution
library(MASS)
# For the data set
ggplot(birthwt, aes(x
=
factor(race), y
=
bwt))
+
geom_boxplot(notch
=
TRUE
TRUE
)