Graphics Reference
In-Depth Information
Figure 2-10. Left: box plot with base graphics; right: with multiple grouping variables
If the two vectors are in the same data frame, you can also use formula syntax. With this syntax,
you can combine two variables on the x-axis, as in
Figure 2-10
:
# Formula syntax
boxplot(len ~ supp, data
=
ToothGrowth)
# Put interaction of two variables on x-axis
boxplot(len ~ supp
+
dose, data
=
ToothGrowth)
m="boxplot"
:
library(ggplot2)
qplot(ToothGrowth$supp, ToothGrowth$len, geom
=
"boxplot"
)