Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change gg_miss_case to be more practical #117

Closed
njtierney opened this issue Nov 22, 2017 · 1 comment
Closed

Change gg_miss_case to be more practical #117

njtierney opened this issue Nov 22, 2017 · 1 comment

Comments

@njtierney
Copy link
Owner

The idea behind gg_miss_case is to give you a sense of how many missings there are in your dataset when we look across the cases (the rows).

However, I'm fairly convinced that the current plotting method (with points and lines) isn't very nice, so I decided to change the plotting method to remove the unnecessary points, and it also comes with a reordering method, where it gives you a sense of how many missings there across cases, ordering from most to least missing.

# ggobject <- 
library(tidyverse)
library(naniar)
gg_miss_case2 <- function(data, order_rows = FALSE){
  
  if (order_rows) {
    miss_case_summary(airquality, order = TRUE) %>%
      # overwrite case
      mutate(case = 1:n()) %>%
      ggplot(data = .,
             aes(x = case,
                 y = n_miss)) +
      geom_col(width = 1,
               colour = "grey",
               fill = "grey") + 
      coord_flip() + 
      labs(y = "# Missing",
           x = "# Cases") +
      theme_minimal() + 
      scale_x_reverse()
    
  } else if (!order_rows) {
  ggplot(data = miss_case_summary(data),
         aes(x = case,
             y = n_miss)) +
  geom_col(width = 1,
           colour = "grey",
           fill = "grey") +
  coord_flip() +
  labs(y = "# Missing",
       x = "Cases") +
  theme_minimal() + 
  scale_x_reverse()
  }
}
# return(ggobject)

gg_miss_case(airquality)

gg_miss_case2(airquality)

gg_miss_case2(airquality, order_rows = TRUE)

@njtierney
Copy link
Owner Author

Current output, from branch - gg-miss-groups

library(naniar)

gg_miss_case(airquality)

gg_miss_case(airquality, order_cases = TRUE)

gg_miss_case(airquality, group = Month)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

No branches or pull requests

1 participant