3

I am trying to visualize missing data patterns. I am using the aggr() function from the VIM package and keep receiving this Warning message:

In plot.aggr(res, ...) : not enough vertical space to display frequencies (too many combinations)

The problem is caused because I am trying to show too much data and cannot figure out how to resize the plot to allow for the extra data. I have 20 variables I'm trying to visualize and it will not fit.


I found this question but the solution does not work.

I've created an example that demonstrates the problem:

df <- data.frame(replicate(25,sample(0:1,1000,rep=TRUE)))

df2 <- as.data.frame(lapply(df, function(cc) cc[ sample(c(TRUE, NA), 
          prob = c(0.85, 0.15), size = length(cc), replace = TRUE) ]))

aggr(df2, plot = TRUE, combined=TRUE, sortVars=FALSE, sortCombs=TRUE,
    numbers=TRUE, prop=c(FALSE, FALSE), only.miss=FALSE, cex.numbers=.6,
    cex.axis=.6)
TeslaStat
  • 75
  • 1
  • 1
  • 6

1 Answers1

4

I realise that this doesn't answer how to do this in VIM, but here are some other methods for visualising missing data using


df <- data.frame(replicate(25,sample(0:1,1000,rep=TRUE)))

df2 <- as.data.frame(lapply(df, function(cc) cc[ sample(c(TRUE, NA), 
                                                        prob = c(0.85, 0.15), size = length(cc), replace = TRUE) ]))


# visualise using visdat
visdat::vis_miss(df2)

# apply clustering
visdat::vis_miss(df2, cluster = TRUE)

# sort the rows
visdat::vis_miss(df2, sort_miss = TRUE)

# visualise the number of missings in cases using visna from extracat
extracat::visna(df2)

# sort by rows
extracat::visna(df2, sort = "r")

# sort by columns
extracat::visna(df2, sort = "c")

# visualise the number of missings in each variable using naniar `gg_miss_var`
naniar::gg_miss_var(df2)

Nick Tierney
  • 192
  • 1
  • 8