用散点图探索缺失数据
在 ggplot2 的散点图中,缺失值默认会被移除,并给出一条警告。
我们可以使用 geom_miss_point() 在散点图中显示缺失值。这个特殊的 ggplot2 几何对象会将缺失值移入图中,显示在该变量最小值下方 10% 的位置。
让我们用 oceanbuoys 数据集来练习这种可视化方法。
本练习是课程的一部分
在 R 中处理缺失数据
练习说明
- 探索风向东西向(
wind_ew)与气温的缺失情况,并使用geom_miss_point()显示缺失值。 - 探索湿度与气温的缺失情况,并使用
geom_miss_point()显示缺失值。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Explore the missingness in wind and air temperature, and
# display the missingness using `geom_miss_point()`
ggplot(oceanbuoys,
aes(x = ___,
y = ___)) +
geom_miss_point()
# Explore the missingness in humidity and air temperature,
# and display the missingness using `geom_miss_point()`
ggplot(___,
aes(x = ___,
y = ___)) +
geom_miss_point()