Aan de slagGa gratis aan de slag

Daily ride counts

A useful way to tabulate and visualize cab rides is by looking at the number of rides according to the calendar day. In this exercise, you'll compute this summary and examine how daily ridership varies by time and the day of week.

The tx data set is preloaded for you.

Deze oefening maakt deel uit van de cursus

Visualizing Big Data with Trelliscope in R

Cursus bekijken

Oefeninstructies

  • Create a daily summary, grouping by the date of pickup (pickup_date) and counting the number of rides, calling the new variable n_rides. Recall that dplyr's n() function provides a count of how many observations are in each group.
  • Plot the result using ggplot2's geom_line(), with pickup_date on the x-axis and n_rides on the y-axis.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

library(dplyr)
library(ggplot2)

# Summarize the number of taxi rides by pickup day
daily_count <- tx %>%
  group_by(___) %>%
  summarise(n_rides = ___)

# Create a line plot
ggplot(daily_count, aes(___, ___)) +
  ___
Code bewerken en uitvoeren