September 2018
Beginner
206 pages
4h 27m
English
When you have one continuous variable, it's a good idea to use a histogram to get an idea of its distribution. The height of the bar of the histogram corresponds to the number of observations that have that value. We can create a histogram of the mpg variable in mtcars using the following code:
ggplot(mtcars, aes(mpg)) + geom_histogram()
This code will throw a warning:
'stat_bin()' using 'bins = 30'. Pick better value with 'binwidth'.

The default number of bins is always 30, and you should always change it and find a better value for your data. The default means that it takes the range of the data (here, mpg is between 10.4 and ...
Read now
Unlock full access