A histogram
displays the distribution of a numeric variable. A common task is to
compare this distribution through several groups. This document explains
how to do so using R and ggplot2
.
Firstly, we create an example data with different distributions.
If the number of group or variable you have is relatively low, you can display all of them on the same axis, using a bit of transparency to make sure you do not hide any data.
This document is a work of the statistics team in the Biostatistics and Medical Information Department at Saint-Louis Hospital in Paris (SBIM).
Based on The R Graph Gallery by Yan Holtz.