Histograms

When talking about data exploration with R, we cannot avoid mentioning histograms, which are a very useful way to gain a view on how your population is distributed along the minimum and maximum value.  Within histograms, the data is binned in more or less regular intervals, and the plotted bar heights are such that the area of bars is proportional to the number of items within each interval. R comes with a convenient hist() function directly within the base version. As mentioned earlier, we are also going to learn how to produce a plot employing the ggplot2 package. At this stage in our journey, you may already be guessing at least some of the lines of code required, especially the first line, which is the usual ggplot() one:

ggplot(data = ToothGrowth, aes(x = len))+ geom_histogram()

This will produce exactly what we are looking for:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset