BaşlayınÜcretsiz Başlayın

Making Graphs of Different User Types

Let's compare graphs of people who subscribe to the divvy bike vs. more casual non-subscribing customers.

It's convenient to use dplyr to manipulate the data before using graph_from_data_frame() to create the graph. One useful dplyr function you'll need is n(), which gives the number of rows in that group of the data frame.

Bu egzersiz

Case Studies: Network Analysis in R

kursunun bir parçasıdır
Kursu Görüntüle

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

subscribers <- bike_dat %>% 
  # Filter for rows where usertype is Subscriber
  ___(___ == "___")

# Count the number of subscriber trips
n_subscriber_trips <- nrow(___)

subscriber_trip_graph <- subscribers %>% 
  # Group by from_station_id and to_station_id
  ___(___, ___) %>% 
  # Calculate summary statistics
  summarize(
    # Set weights as proportion of total trips
    weights = ___() / n_subscriber_trips
  ) %>%
  # Make a graph from the data frame
  graph_from_dataframe()
Kodu Düzenle ve Çalıştır