依遺漏情形探索變異:盒鬚圖
先前的練習使用 nabular 資料搭配機率密度圖,依據另一個變數是否遺漏來探索某變數的變異。
這裡我們改用 naniar 套件裡的 oceanbuoys 資料集,並以盒鬚圖來取代分面或其他方式,探索不同層次的遺漏情形。
本練習屬於課程
在 R 中處理遺漏值
練習說明
- 使用
geom_boxplot(),針對空氣溫度是否遺漏來探索東西向風速(wind_ew)的分佈。 - 進一步在視覺化上加入分面,依據濕度是否遺漏(
humidity_NA)進行分面。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Explore the distribution of wind east west (`wind_ew`) for
# the missingness of air temperature using `geom_boxplot()`
oceanbuoys %>%
bind_shadow() %>%
ggplot(aes(x = air_temp_c___,
y = ____)) +
geom_____()
# Build upon this visualization by faceting by the missingness of humidity (`humidity_NA`).
oceanbuoys %>%
___() %>%
ggplot(aes(x = ___,
y = ___)) +
geom_____() +
facet_wrap(~___)