This section introduces the functionality of the base-R function boxplot. Note that for some data formats, the plot function with x being a factor variable will also work.
Draw a box plot of teeth length (len):
# Box plot of one variable boxplot(ToothGrowth$len) # Box plots by groups (dose) # remove frame boxplot(len ~ dose, data = ToothGrowth, frame = FALSE) # Horizontal box plots boxplot(len ~ dose, data = ToothGrowth, frame = FALSE, horizontal = TRUE) # Notched box plots boxplot(len ~ dose, data = ToothGrowth, frame = FALSE, notch = TRUE)
Notch is used to compare groups. In the notched boxplot, if two boxes' notches do not overlap this is "strong evidence" their medians differ (Chambers et al., 1983, p. 62).