用 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 中處理遺漏值

一起來練習吧!

在 R 中處理遺漏值

Preparing Video For Download...