Section 16 One Numeric: boxplot

16.1 Boxplot

The function boxplot produces the box-and-whisker plot(s) of the given values or grouped data.

16.2 Example 1

data(iris)

?boxplot

x <- iris$Sepal.Length
str(x)
 num [1:150] 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
boxplot(x)

x <- iris$Sepal.Length
str(x)
 num [1:150] 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
boxplot(x, lty=1, lwd=2, col='lightblue')

boxplot(x, lty=1, lwd=1.25, col='lightblue',
     main='Density of Sepal Length',
     xlab='All Data',
     ylab='Sepal Length (cm)',
     border='blue')

boxplot(x, lty=1, lwd=1.25, col='lightblue',
     main='Density of Sepal Length',
     xlab='All Data',
     ylab='Sepal Length (cm)',
     border='blue', horizontal=TRUE)

16.3 Example 2

data(warpbreaks)

  • Draw a box plot of the variable breaks

  • Discuss the box plot

  • Transform the data using log-transformation and redraw the box plot