Welcome to the histogram section of the R graph gallery. A histogram is used to study the distribution of one or several variables, as explained in data-to-viz.com. If you're looking for a simple way to implement it in R, pick an example below. This page focuses on ggplot2 but base R examples are also provided.
Histograms can be built with ggplot2
thanks to the
geom_histogram()
function. It requires only 1 numeric
variable as input. This function automatically cut the variable in
bins and count the number of data point per bin. Remember to try
different bin size
using the binwidth
argument.
Of course it is possible to build high quality histograms without
ggplot2
or the tidyverse
. Here are a few
examples illustrating how to proceed.