Get startedGet started for free

Most Traveled To and From Stations

Here we'll look at which stations are most commonly traveled to and from, as well as the ratio of in to out degree. This will tell us which stations are skewed as either having many stations pulling bikes from them or leaving bikes at them. In order for a bike sharing graph like this to work effectively, you can't have too many source or sink stations, otherwise the owner of the network would need to be constantly moving around bikes! Ideally, the network is designed to self correct, and if it's doing that, we expect to see almost all the stations with an in to out degree ratio of around one. First, we're going to look at this in the unweighted case.

This exercise is part of the course

Case Studies: Network Analysis in R

View Course

Exercise instructions

  • Create a data frame containing the following columns.
    • trip_out should contain the "out" degree distribution of trip_g_simp.
    • trip_in should contain the "in" degree distribution.
    • ratio should contain the ratio of "out" degrees divided by "in" degrees.
  • Filter trip_deg for rows where both trip_out and trip_in are greater than 10.
  • Plot a histogram of the filtered ratios.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

trip_deg <- data_frame(
  # Find the "out" degree distribution
  trip_out = degree(___, mode = "___"), 
  # ... and the "in" degree distribution
  trip_in = degree(___, mode = "in")
  # Calculate the ratio of out / in
  ratio = ___ / trip_in
)

trip_deg_filtered <- trip_deg %>%
  # Filter for rows where trips in and out are both over 10
  ___(___ > 10, ___ > 10) 

# Plot histogram of filtered ratios
hist(___$ratio)
Edit and Run Code