开始使用免费开始使用

可视化缺失模式

让我们练习几种不同的方法来可视化缺失模式:

  • 使用 gg_miss_upset() 查看整体缺失模式。
  • 在包含关注因子(婚姻状况)的数据集中使用 gg_miss_fct()
  • 使用 gg_miss_span() 探索时间序列数据中的缺失情况。

结合数据中的缺失与分面,您观察到了什么?

本练习是课程的一部分

在 R 中处理缺失数据

查看课程

练习说明

  • 使用 gg_miss_upset() 探索 airquality 数据集的缺失模式。
  • 使用 gg_miss_fct() 探索 riskfactors 数据集中 marital 变量上的缺失如何变化。
  • pedestrian 数据集中,针对 hourly_counts 变量,按跨度 3000 探索缺失如何变化(您也可以尝试 2000–5000 的不同跨度)。
  • month 放入 facet 参数,跨度设为 1000,探索其对 hourly_counts 的影响。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Using the airquality dataset, explore the missingness pattern using gg_miss_upset()
gg_miss_upset(airquality)

# With the riskfactors dataset, explore how the missingness changes across the marital variable using gg_miss_fct()
gg_miss_fct(x = riskfactors, fct = marital)

# Using the pedestrian dataset, explore how the missingness of hourly_counts changes over a span of 3000 
gg_miss_span(pedestrian, var = ___, span_every = ___)

# Using the pedestrian dataset, explore the impact of month by faceting by month
# and explore how missingness changes for a span of 1000
____(___, var = ___ , span_every = ___, facet = ___)
编辑并运行代码