Get startedGet started for free

Visualizing missingness patterns

Let's practice a few different ways to visualize patterns of missingness using:

  • gg_miss_upset() to give an overall pattern of missingness.
  • gg_miss_fct() for a dataset that has a factor of interest: marriage.
  • and gg_miss_span() to explore the missingness in a time series dataset.

What do you notice with the missingness and the faceting in the data?

This exercise is part of the course

Dealing With Missing Data in R

View Course

Exercise instructions

  • Explore missingness pattern of the airquality dataset with gg_miss_upset().
  • Explore how the missingness changes in the riskfactors dataset across the marital variable using gg_miss_fct()
  • Explore how the missingness changes in the pedestrian dataset across the hourly_counts variable over a span of 3000 (you can also try different spans from 2000-5000).
  • Explore the impact of month on hourly_counts by including it in the facet argument, with a span of 1000.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# 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 = ___)
Edit and Run Code