R Data Analysis Cookbook, Second Edition - Second Edition
by Kuntal Ganguly, Davor Lozić, Mzabalazo Z. Ngwenya, Andrew Bauman, Shanthi Viswanathan, Viswa Viswanathan
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access