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)
With the ggplot2 package, you can get a similar result using qplot() ( Figure 2-11 ), with geo-
m="boxplot" :
library(ggplot2)
qplot(ToothGrowth$supp, ToothGrowth$len, geom = "boxplot" )
Search WWH ::




Custom Search