How to add number of observations to a ggplot2 boxplot

Dr. Gregor Scheithauer
3 min readSep 6, 2018

Introduction

Boxplots are extremely useful to learn more about any given dataset. Basically, it allows you to compare a continuous and a categorical variable, that includes information about distribution and statistics, such as the median. As an example, let us explore the Iris dataset.

Let’s say you want to know more about the variable Sepal.Length. One way to do this would be to look at its statistics.

summary(iris$Sepal.Length)##    Min. 1st Qu

--

--