O'Reilly logo

R Data Analysis Cookbook - Second Edition by Kuntal Ganguly

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How it works...

Step 1: All geom_histogram() geometry requires is a single quantitative column from a data frame or a single vector of data. In this recipe, we use the faithful dataset, which contains data about the Old Faithful geyser in two columns: eruptions, referring to the length of each eruption, and waiting, referring to the length of time until the next eruption.

Step 2: The geom_histogram(), by default, groups data into 30 bins and it may be too fine or too coarse for your data. We can change the size of the bins using the binwidth parameter.

Step 3: We used the density curve to compare the theoretical and observed distributions by overlaying it with the histogram. The area under the density curve always sums to 1. Histogram result ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required