Skip to content

Instantly share code, notes, and snippets.

@vsbuffalo
Created August 22, 2014 18:44
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vsbuffalo/a2c48027e177c7d25c89 to your computer and use it in GitHub Desktop.
Save vsbuffalo/a2c48027e177c7d25c89 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