Histogram
Histogram
A histogram is good for showing the distribution of a single numerical variable. It can give you an idea of whether your data is normally distributed or skewed.
The code for a histogram is slightly different than the basic format because for a histogram, you only need to specify the x variable because the y variable is always count (kinda similar to the geom_bar() function).
Let’s make a histogram of the weights of all the penguins:
You’ll notice it says something about using 30 bins and that you can pick a better value. The number of bins determines how our data broken is broken up into groups that become the columns. The easiest way to understand bins is just to change the number of them and see the results on the graph. Start with this code that uses 10 and change that number to see how the graph changes. (R usually does a pretty good job picking the number of bins, so it’s often not necessary to specify them.)