diff --git a/R/gg-miss-which.R b/R/gg-miss-which.R index c9f154da..649fb41f 100644 --- a/R/gg-miss-which.R +++ b/R/gg-miss-which.R @@ -21,12 +21,13 @@ gg_miss_which <- function(x){ + col_na <- colSums(is.na(x)) == 0 + col_na_val <- dplyr::if_else(col_na, "complete", "missing") + + # tell us which columns have missing data - ggobject <- x %>% - miss_var_summary() %>% - dplyr::select(variable, - value = n_miss) %>% - dplyr::mutate(value = dplyr::if_else(value == 0, "complete", "missing")) %>% + ggobject <- tibble::tibble(variable = names(col_na), + value = col_na_val) %>% dplyr::mutate(nheight = 1) %>% ggplot(data = ., aes(x = variable, diff --git a/R/where-na.R b/R/where-na.R index 36077dde..97bb5e69 100644 --- a/R/where-na.R +++ b/R/where-na.R @@ -79,7 +79,7 @@ miss_var_which <- function(data){ } # else return variables that contain ANY missing values - na_vars <- names(which(purrr::map_lgl(data,anyNA) == TRUE)) + na_vars <- names(which(colSums(is.na(data)) > 0)) return(na_vars)