為插補後的資料建立直方圖
既然我們能重現 geom_miss_point() 的第一個視覺化,接下來看看如何把這個想法應用到其他探索式任務。
一個實用的任務是用直方圖評估某個變數中的遺漏值數量。我們可以使用上一個練習建立、並已載入到本工作階段的 ocean_imp_track 資料集來完成。
本練習屬於課程
在 R 中處理遺漏值
練習說明
使用插補並追蹤後的資料 ocean_imp_track:
- 探索
air_temp_c的數值,並用air_temp_c_NA視覺化其遺漏量。 - 使用
humidity_NA探索humidity的遺漏情形。 - 依年份探索
air_temp_c的遺漏情形,使用facet_wrap(~year)。 - 依年份探索
humidity的遺漏情形,使用facet_wrap(~year)。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Explore the values of air_temp_c, visualizing the amount of missings with `air_temp_c_NA`.
p <- ggplot(___, aes(x = ___, fill = ___)) + ___()
# Expore the missings in humidity using humidity_NA
p2 <- ggplot(___, aes(x = ___, fill = ___)) + ___()
# Explore the missings in air_temp_c according to year, using `facet_wrap(~year)`.
p + facet_wrap(~___)
# Explore the missings in humidity according to year, using `facet_wrap(~year)`.
p2 + facet_wrap(~___)