Skip to content

Commit

Permalink
reduce use of map_dfc and gather for code speedup in gg_miss_which
Browse files Browse the repository at this point in the history
  • Loading branch information
njtierney committed May 19, 2020
1 parent d4349a5 commit 79a12e8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
8 changes: 4 additions & 4 deletions R/gg-miss-which.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 79a12e8

Please sign in to comment.