Creating box plots

In this recipe, you will learn how to make box plots that are useful in comparing the spread of values in different measurements.

Getting ready

First, we need to load the metals.csv example data file that contains measurements of metal concentrations in London's air (you can download this file from the code download section of the book's companion website):

metals<-read.csv("metals.csv",header=TRUE)

How to do it...

We can make a box plot to summarize the metal concentration data using the boxplot() command as follows:

boxplot(metals,
xlab="Metals",
ylab="Atmospheric Concentration in ng per cubic metre",
main="Atmospheric Metal Concentrations in London")

How it works...

The main argument, the boxplot() function, takes a set of numeric ...

Get R: Data Analysis and Visualization now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.