最常往返的站点
这里我们将查看哪些站点最常被骑行到达与出发,并计算入度与出度的比值。这有助于判断哪些站点更偏向于被"抽走"单车,或更常被"存放"单车。为了让这样的共享单车网络有效运行,不能有太多"源站"或"汇站",否则运营方就需要不停地调运单车!理想情况下,网络会自我平衡。如果确实如此,我们预计几乎所有站点的入度与出度之比应当接近 1。首先,我们将在未加权的情况下进行观察。
本练习是课程的一部分
案例研究:用 R 进行网络分析
练习说明
- 创建一个包含以下列的数据框。
trip_out:包含trip_g_simp的"out"度分布。trip_in:包含"in"度分布。ratio:包含 "out" 度与 "in" 度的比值("out" 除以 "in")。
- 过滤
trip_deg,仅保留trip_out和trip_in都大于10的行。 - 绘制过滤后比值的直方图。
交互式实操练习
通过完成这段示例代码来试试这个练习。
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)