In this recipe, we will see how we can summarize data for a variable with respect to another variable in the dataset. We will learn to group over a variable such that a separate box plot is created for each group.
We will only use the base graphics functions for this recipe. So, just open up the R prompt and type in the following code. We will use the metals.csv
example dataset for this recipe. So, let's first load it:
metals<-read.csv("metals.csv")
Let's make a box plot that shows copper (Cu
) concentrations grouped over measurement sites:
boxplot(Cu~Source,data=metals, main="Summary of Copper (Cu) concentrations by Site")