使用 ggplot 探索条件缺失

在 R 中处理缺失数据

Nicholas Tierney

Statistician

本节内容

  • 如何使用 nabular 数据探索:当其他值缺失时,数值如何变化
  • 将展示:
    • 密度图
    • 箱线图
    • 不同的分割可视化方法
在 R 中处理缺失数据

用密度图可视化缺失

ggplot(airquality,
       aes(x = Temp)) + 
  geom_density()

在 R 中处理缺失数据

用密度图可视化缺失

airquality %>%
  bind_shadow() %>%
  ggplot(aes(x = Temp,
             color = Ozone_NA)) + 
  geom_density()

在 R 中处理缺失数据

用箱线图可视化缺失

airquality %>%
  bind_shadow() %>%
  ggplot(aes(x = Ozone_NA,
             y = Temp)) + 
  geom_boxplot()

在 R 中处理缺失数据

用分面可视化缺失

airquality %>%
  bind_shadow() %>%
  ggplot(aes(x = Temp)) + 
  geom_density() + 
  facet_wrap(~Ozone_NA)

在 R 中处理缺失数据

用分面可视化缺失

airquality %>%
  bind_shadow() %>%
  ggplot(aes(x = Temp,
             y = Wind)) + 
  geom_point() +
  facet_wrap(~ Ozone_NA)

在 R 中处理缺失数据

用颜色可视化缺失

airquality %>%
  bind_shadow() %>%
  ggplot(aes(x = Temp,
             y = Wind,
             color = Ozone_NA)) + 
  geom_point()

在 R 中处理缺失数据

叠加缺失层次

airquality %>%
  bind_shadow() %>%
  ggplot(aes(x = Temp,
             color = Ozone_NA)) + 
  geom_density()  +
  facet_wrap(~ Solar.R_NA)

在 R 中处理缺失数据

Vamos praticar!

在 R 中处理缺失数据

Preparing Video For Download...