欠損パターンの可視化
次の関数を使って、欠損のパターンを可視化する練習をしましょう。
- 全体的な欠損パターンには
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 = ___)