It is often useful to know the number of observations for each variable or group when comparing them on a box plot. We did this earlier with the varwidth
argument that makes the widths of boxes proportional to the square root of the number of observations. In this recipe, we will learn how to display the number of observations on a box plot.
We will continue using the base graphics library functions, so we need not load any additional library or package. We just need to run the recipe code at the R prompt. We can also save the code as a script to use it later. Here, we will use the metals.csv
example dataset again:
metals<-read.csv("metals.csv")