Bar charts are usually used to explore how one (or more) categorical variables are distributed. In ggplot, the geom_bar geometry counts the number of occurrences of each factor variable that appears in the data. This recipe shows you how to create bar graphs that enable segment-wise comparisons with different variable types.
Creating bar graphs
Getting ready
If you have not already done so, download the book's files for this chapter and save the daily-bike-rentals.csv file in your R working directory. Read the data into R using the following command, and also check the packages needed:
> library(ggplot2)
> library(dplyr)
> bike <- read.csv("daily-bike-rentals.csv")
> bike$season <- factor...