From the course: Data Visualization in R with ggplot2
Unlock this course with a free trial
Join today to access over 24,700 courses taught by industry experts.
Histograms
From the course: Data Visualization in R with ggplot2
Histograms
- [Instructor] Histograms are a special case of bar graphs that allow us to work with continuous variables that don't easily lend themselves to bar graphs. Let's look at an example. Say that I want to create a bar graph showing how many institutions have different numbers of undergraduate students. I could try to do this with a standard bar graph. We'll just run ggplot against the college dataset, and then ask for a bar geometry. And my mapping will be undergrads on the x-axis. Now, this plot isn't very helpful because the values for undergraduates are continuous. They can take on almost any value. In our dataset, we have an institution that has only 27 undergraduate students and another that has over 50,000. As you can see from this plot, there aren't many that have the same exact number. Histograms help us by grouping values like these into bins. We might have one bar for institutions between zero and 1,000 students, another for one to 2,000 and so on. That process of grouping…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.