Graphics Reference
In-Depth Information
by using
factor(race)
inside of the
aes()
statement. In the preceding example, we used
factor(race)
.
A box plot consists of a box and “whiskers.” The box goes from the 25th percentile to the 75th
percentile of the data, also known as the inter-quartilerange(IQR). There's a line indicating the
median, or 50th percentile of the data. The whiskers start from the edge of the box and extend
to the furthest data point that is within 1.5 times the IQR. If there are any data points that are
past the ends of the whiskers, they are considered outliers and displayed with dots.
Figure 6-16
shows the relationship between a histogram, a density curve, and a box plot, using a skewed data
set.
Figure 6-16. Box plot compared to histogram and density curve
ggplot(birthwt, aes(x
=
factor(race), y
=
bwt))
+
geom_boxplot(width
=
.5
)