Converts NA values in any factors in the dataframe into a new level -
This is a thin wrapper for forcats::fct_explicit_na() but with missing
value level added regardless of whether any values missing. This forces an
empty row in count tables.
Examples
# before
missing_diamonds %>% dplyr::group_by(cut) %>% dplyr::count()
#> # A tibble: 6 × 2
#> # Groups:   cut [6]
#>   cut           n
#>   <ord>     <int>
#> 1 Fair       1454
#> 2 Good       4462
#> 3 Very Good 10816
#> 4 Premium   12460
#> 5 Ideal     19361
#> 6 NA         5387
# after
missing_diamonds %>% explicit_na() %>% dplyr::group_by(cut) %>% dplyr::count()
#> # A tibble: 6 × 2
#> # Groups:   cut [6]
#>   cut           n
#>   <fct>     <int>
#> 1 Fair       1454
#> 2 Good       4462
#> 3 Very Good 10816
#> 4 Premium   12460
#> 5 Ideal     19361
#> 6 <missing>  5387
