From the course: Data Visualization in R with ggplot2
Unlock this course with a free trial
Join today to access over 24,300 courses taught by industry experts.
Bars and columns
From the course: Data Visualization in R with ggplot2
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…
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.