Skip to content

Instantly share code, notes, and snippets.

@gavinsimpson
gavinsimpson / asciify.R
Last active September 7, 2016 05:32
Create a MySQL-like ASCII table of data
asciify <- function(df, pad = 1, ...) {
## error checking
stopifnot(is.data.frame(df))
## internal functions
SepLine <- function(n, pad = 1) {
tmp <- lapply(n, function(x, pad) paste(rep("-", x + (2* pad)),
collapse = ""),
pad = pad)
paste0("+", paste(tmp, collapse = "+"), "+")
}