In this recipe, you will learn how to make box plots that are useful in comparing the spread of values in different measurements.
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)
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")
The main argument, the boxplot()
function, takes a set of numeric values (in the form of a vector or data frame). In our first example, we used a dataset containing numerical values of air pollution data from London. The dark line inside the box for each metal represents the median of values for that metal. The...