diff --git a/NEWS.md b/NEWS.md index 9b901d15..fc4413e2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,8 +2,8 @@ ## Minor Changes -- Improved code in `miss_var_summary()`, `miss_var_table()`, and - `prop_miss_var()`, improving speed. +- Improvements to code in `miss_var_summary()`, `miss_var_table()`, and + `prop_miss_var()`, resulting in a 3-10x speedup. # naniar 0.5.1 (2020/04/10) "Uncle Andrew's Applewood Wardrobe" diff --git a/R/gg-miss-which.R b/R/gg-miss-which.R index 4949f236..c9f154da 100644 --- a/R/gg-miss-which.R +++ b/R/gg-miss-which.R @@ -23,10 +23,10 @@ gg_miss_which <- function(x){ # tell us which columns have missing data ggobject <- x %>% - purrr::map_dfc(anyNA) %>% - purrr::map_dfc(function(x) ifelse(x == 0, "complete", "missing")) %>% - tidyr::gather(key = "variable", - value = "value") %>% + miss_var_summary() %>% + dplyr::select(variable, + value = n_miss) %>% + dplyr::mutate(value = dplyr::if_else(value == 0, "complete", "missing")) %>% dplyr::mutate(nheight = 1) %>% ggplot(data = ., aes(x = variable,