簡單的箱型圖
先從建立一個和投影片中類似的箱型圖開始。
把 filter() 改成篩選成 'RED' 車輛(而不是藍色),接著把 x 軸對應到 gender,y 軸對應到駕駛的 speed。加入箱型圖的幾何物件,並替圖表加上一個標題。
本練習屬於課程
R 視覺化最佳實務
練習說明
- 修改
filter()指令,僅保留'RED'車輛。 - 在
aes()中將x對應到gender,y對應到speed。 - 在圖中加入箱型圖的幾何物件。
- 將圖表標題設為
'Speed of red cars by gender of driver'。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
md_speeding %>%
filter(vehicle_color == 'BLUE') %>%
# Map x and y to gender and speed columns respectively
ggplot(aes(___)) +
# add a boxplot geometry
___ +
# give plot supplied title
labs(title = '___')