Now we'll look at how to generate histograms of the count of daily bike rentals by season, using R's base plotting system:
- Set up a 2 x 2 grid for plotting histograms for the four seasons:
> par(mfrow = c(2,2))
- Extract data for seasons:
> spring <- subset(bike, season == "Spring")$cnt > summer <- subset(bike, season == "Summer")$cnt > fall <- subset(bike, season == "Fall")$cnt > winter <- subset(bike, season == "Winter")$cnt
- Plot the histogram, density, mean, and median for each season:
> hist(spring, prob=TRUE, xlab = "Spring daily rentals", main = "")> lines(density(spring))> abline(v = mean(spring), col = "red")> abline(v = median(spring), col = "blue")> hist(summer, prob=TRUE, xlab = "Summer daily rentals", ...