How to use the boxplot() function in R and how to do multiple boxplots of a variable based on groups. For example, in our example we have the heights from three hockey teams. Instead of doing a boxplot on height, we can get three boxplots of height for each team side-by-side, which allows a more fair comparison of the spread of data.