始める無料で始める

欠損パターンの可視化

次の関数を使って、欠損のパターンを可視化する練習をしましょう。

  • 全体的な欠損パターンには gg_miss_upset()
  • 関心のある因子(ここでは結婚:marriage)をもつデータセットには gg_miss_fct()
  • 時系列データの欠損を探るには gg_miss_span()

欠損とファセット化の結果について、どんな点に気づきますか?

この演習はコースの一部です

Rでの欠損データの扱い方

コースを見る

演習の手順

  • airquality データセットの欠損パターンを gg_miss_upset() で確認します。
  • riskfactors データセットで、marital 変数に沿って欠損がどのように変化するかを gg_miss_fct() で確認します。
  • pedestrian データセットで、hourly_counts 変数の欠損がスパン3000でどのように変化するかを確認します(2000〜5000の範囲で他のスパンも試せます)。
  • スパン1000で、facet 引数に month を指定して、hourly_counts に対する month の影響を探索します。

実践的なインタラクティブ演習

このサンプルコードを完成させて、この演習に挑戦してみましょう。

# 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 = ___)
コードを編集して実行