CommencerCommencer gratuitement

Plotting graphs on a map

In this lesson, we'll build a map that overlays the bike graph on a map. We'll then color the edges by subscriber/non-subscriber and draw the thickness by the number of trips. First, recall that subscribers to the bike sharing network are regular users and probably more likely to be local, whereas non-subscribers are more likely to be tourists. Trips from non-subscribers tend to be limited to the lakefront portions of the city that tend to have more tourist attractions. Another pattern we'll see is that the further west a station is, the thinner the line, meaning fewer trips were taken. Overlaying the graph on the map helps make certain network patterns much clearer than if we were to simply make a regular hairball plot.

The bike data, bike_dat, and a map of Chicago, chicago, are available.

Cet exercice fait partie du cours

Case Studies: Network Analysis in R

Afficher le cours

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

weighted_trips_by_usertype <- bike_dat %>% 
  group_by(
    from_station_id, to_station_id, 
    from_latitude, from_longitude, 
    to_latitude, to_longitude, 
    usertype
  ) %>% 
  # Weight each journey by number of trips
  ___(___ = ___)
Modifier et exécuter le code