`ggmice::plot_pattern()` produces an error if the data does not contain missings
thomvolker opened this issue · comments
library(mice)
#>
#> Attaching package: 'mice'
#> The following object is masked from 'package:stats':
#>
#> filter
#> The following objects are masked from 'package:base':
#>
#> cbind, rbind
library(ggmice)
#>
#> Attaching package: 'ggmice'
#> The following objects are masked from 'package:mice':
#>
#> bwplot, densityplot, stripplot, xyplot
library(ggplot2)
dat <- mice(boys, m = 1) %>% complete
#>
#> iter imp variable
#> 1 1 hgt wgt bmi hc gen phb tv reg
#> 2 1 hgt wgt bmi hc gen phb tv reg
#> 3 1 hgt wgt bmi hc gen phb tv reg
#> 4 1 hgt wgt bmi hc gen phb tv reg
#> 5 1 hgt wgt bmi hc gen phb tv reg
plot_pattern(dat)
#> /\ /\
#> { `---' }
#> { O O }
#> ==> V <== No need for mice. This data set is completely observed.
#> \ \|/ /
#> `-----'
#> Error in `chr_as_locations()`:
#> ! Can't subset columns that don't exist.
#> ✖ Columns `age`, `hgt`, `wgt`, `bmi`, `hc`, etc. don't exist.
Created on 2022-07-06 by the reprex package (v2.0.1)
Not per se a big issue, but a simple message that the data is fully observed would probably suffice, rather than throwing an error.
I might look into it later today or tomorrow, but it's probably easy to fix.
Thank you!