课程: Data Visualization in R with ggplot2

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

Histograms

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…

内容