课程: Data Visualization in R with ggplot2

免费学习该课程!

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

Bars and columns

Bars and columns

- [Instructor] Bar graphs are another common data visualization tool. In ggplot, we can use two different functions to create bar graphs. geom_bar() creates a bar graph where we specify the value that appears on the X-axis and use the count of the number of rows matching that value. as the Y-axis value. geom_col() call creates a column graph, which like bar graphs allows us to specify the value on the X-axis, but it also allows us to specify the value on the Y-axis. These two functions are very similar. They only differ in the fact that bars use the count as the Y-axis value while columns allow us to choose the Y-axis value. Let's try some examples in R. We've got our dataset loaded, and let's say, I want to know how many schools are in each region. That calls for a bar graph. I'm going to use the ggplot function and once again say, data=college. And then, I'm going to ask for a geom_bar to create a bar graph, and then use a mapping to set my aesthetic. And I'm going to specify the…

内容