I've been puzzling over why I was seeing a column with 100 percent missing data in a large tibble (~30,000 rows) made up of several tibbles combined with bind_rows() despite seeing that one of the individual tibbles does not show 100% missing for that column.
After a bunch of wild goose chases, I realized that the issue was that miss_var_summary() (and probably similar naniar functions) was rounding the pct_miss column up.
library(tidyverse)
library(naniar)
df <- tibble(x = rep(NA_real_, 30000)) %>%
add_row(x = 0)
df %>% miss_var_summary()
#> # A tibble: 1 x 3
#> variable n_miss pct_miss
#> <chr> <int> <dbl>
#> 1 x 30000 100.
df %>% filter(!is.na(x))
#> # A tibble: 1 x 1
#> x
#> <dbl>
#> 1 0
In this example, the percent missing is actually 99.9967%.
All that to say, I'd like to suggest that for the edge cases of near-zero and near-100 percent missings not be rounded to avoid this confusion.
I've been puzzling over why I was seeing a column with 100 percent missing data in a large tibble (~30,000 rows) made up of several tibbles combined with
bind_rows()despite seeing that one of the individual tibbles does not show 100% missing for that column.After a bunch of wild goose chases, I realized that the issue was that
miss_var_summary()(and probably similar naniar functions) was rounding thepct_misscolumn up.In this example, the percent missing is actually 99.9967%.
All that to say, I'd like to suggest that for the edge cases of near-zero and near-100 percent missings not be rounded to avoid this confusion.