在散点图中可视化插补值
现在,让我们复现第三章中用到 geom_miss_point() 的其中一幅图。
为此,您需要将数据插补到观测范围之下。这是一种用于探索数据的特殊插补方式。通过这一步,您将练习我们需要掌握的要点:如何跟踪缺失值。要把数据插补到数据范围以下,请使用函数 impute_below_all()。
本练习是课程的一部分
在 R 中处理缺失数据
练习说明
使用 oceanbuoys 数据:
- 使用
bind_shadow()、impute_below_all()和add_label_shadow()对缺失值进行插补并进行跟踪。 - 分别在 x 轴与 y 轴上可视化风速与气温的缺失情况,并用
air_temp_c_NA为缺失的气温着色。 - 分别在 x 轴与 y 轴上可视化湿度与气温,并用变量
any_missing为任意存在缺失的观测着色。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Impute and track the missing values
ocean_imp_track <- bind_shadow(___) %>%
impute_below_all() %>%
add_label_shadow()
# Visualize the missingness in wind and air temperature,
# coloring missing air temp values with air_temp_c_NA
ggplot(___,
aes(x = ___, y = ___, color = ___)) +
geom_point()
# Visualize humidity and air temp, coloring any missing cases using the variable any_missing
ggplot(___,
aes(x = ___, y = ___, color = ___)) +
geom_point()