檢視一天中的時段
現在來看看依一天中的時段來看,騎乘分布的情況。請做出一張摘要圖:以每週騎乘次數為主,並依起始小時進行分面,同時區分工作日/週末。
本練習屬於課程
使用 R 的 Trelliscope 視覺化巨量資料
練習說明
- 對於起始週(
start_wk)、一天中的起始小時(start_hod)以及weekday的每種組合,計算騎乘次數n。 - 使用散點將
n繪在 y 軸、start_wk繪在 x 軸,並以weekday決定點的顏色。 - 以
start_hod分面,讓面板呈現 1 列、24 欄(一天 24 小時各一欄),使用facet_grid()。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
library(dplyr)
library(ggplot2)
# Compute week_hod
week_hod <- bike %>%
___ %>%
___
# Plot the result
ggplot(week_hod, aes(___, ___, color = ___)) +
___ +
facet_grid(~ ___) +
scale_y_sqrt()