In this recipe, we will learn how to remove outliers from a box plot. This is usually not a good idea because highlighting outliers is one of the benefits of using box plots. However, sometimes extreme outliers can distort the scale and obscure the other aspects of a box plot, so it is helpful to exclude them in those cases.
Let's continue using the metals.csv
example dataset. So, let's first make sure it has been loaded:
metals<-read.csv("metals.csv")
Once again, we will use the base graphics boxplot()
function with a specific argument to make our metal concentrations box plot without outliers:
boxplot(metals[,-1],outline=FALSE, main="Summary of metal concentrations by Site (without outliers)")
3.15.226.147