Examining time-of-day
Now let's look at how rides are distributed according to the time of day. Let's make a summary plot of weekly ride counts faceted by start hour of day and broken down by workweek/weekend.
This exercise is part of the course
Visualizing Big Data with Trelliscope in R
Exercise instructions
- Compute the number of rides,
n, for each combination of start week (start_wk), start hour of day (start_hod), andweekday. - Use points to plot
non the y-axis andstart_wkon the x-axis and color the points byweekday. - Facet on
start_hodsuch that there is one row of panels and 24 columns, one for each hour of day, usingfacet_grid().
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
library(dplyr)
library(ggplot2)
# Compute week_hod
week_hod <- bike %>%
___ %>%
___
# Plot the result
ggplot(week_hod, aes(___, ___, color = ___)) +
___ +
facet_grid(~ ___) +
scale_y_sqrt()