R/Plotting/gg_missmap.r

#John Spaw
#Inspired by Nicholas Tierney
#Create plot of missing data 

require(dplyr)
require(reshape2)
require(ggplot2)
require(ggthemes)

ggplot_missing <- function(x){
  plot_colors <- c("#22556F", "#FCB729") 
  x %>% 
    is.na %>%
    melt %>%
    ggplot(data = .,
           aes(x = Var2,
               y = Var1)) +
    geom_raster(aes(fill = value)) +
    scale_fill_manual(values = plot_colors,
                      labels = c("Present","Missing")) +
    theme_fivethirtyeight() + 
    theme(axis.text.x  = element_text(angle=90, vjust=0.5)) 
}
JohnPSpaw/JohnPSpawTools documentation built on May 8, 2019, 1:43 p.m.