为填补后的数据创建直方图
既然我们已经能够重现 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(~___)