R/misc.R
Generate missingness patterns using mice::md.pattern(),
with options to reduce the complexity of the output.
md_pattern(data, only_vars_with_missings = TRUE, min_freq = 0.01)
| data | the dataset |
|---|---|
| only_vars_with_missings | defaults to TRUE, omitting variables that have no missings |
| min_freq | minimum number of rows to have this missingness pattern |
data("nhanes", package = "mice") md_pattern(nhanes)#> # A tibble: 6 x 6 #> description hyp bmi chl var_miss n_miss #> <chr> <int> <int> <int> <int> <dbl> #> 1 Missings per variable 8 9 10 27 27. #> 2 Missings in 0 variables 1 1 1 0 13. #> 3 Missings in 3 variables 0 0 0 3 7. #> 4 Missings in 1 variables 1 1 0 1 3. #> 5 Missings in 1 variables 1 0 1 1 1. #> 6 Missings in 2 variables 0 0 1 2 1.md_pattern(nhanes, only_vars_with_missings = FALSE, min_freq = 0.2)#> # A tibble: 4 x 7 #> description age hyp bmi chl var_miss n_miss #> <chr> <int> <int> <int> <int> <int> <dbl> #> 1 Missings per variable 0 8 9 10 27 27. #> 2 Missings in 0 variables 1 1 1 1 0 13. #> 3 Missings in 3 variables 1 0 0 0 3 7. #> 4 3 other, less frequent patterns 3 2 1 2 4 5.