Skip to content

Instantly share code, notes, and snippets.

@jrherr
Forked from vsbuffalo/missing.R
Created August 23, 2014 18:33
Show Gist options
  • Save jrherr/865dda57ac9778261760 to your computer and use it in GitHub Desktop.
Save jrherr/865dda57ac9778261760 to your computer and use it in GitHub Desktop.
# A quick function to save a PBM (http://en.wikipedia.org/wiki/Netpbm_format)
# visualize *a lot* of missing data pretty quickly (outside of R).
writeMissingPBM <- function(x, file) {
dims <- dim(x)
x[] <- as.integer(is.na(x))
con <- file(file, open="wt")
writeLines(sprintf("P1\n%d %d", ncol(x), nrow(x)), con)
write.table(x, file=con, sep=" ", col.names=FALSE, row.names=FALSE, quote=FALSE)
close(con)
}
# use this to save a file, then run:
# cat yourfile.pbm | pnmtopng > yourfile.png
# you will likely need to zoom in on large files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment