Skip to content

Instantly share code, notes, and snippets.

@johnjosephhorton
Created March 7, 2012 02:20
Show Gist options
  • Save johnjosephhorton/1990485 to your computer and use it in GitHub Desktop.
Save johnjosephhorton/1990485 to your computer and use it in GitHub Desktop.
Code snipped for turning Postgresql stdout of a table into an R data frame
get.sql.out <- function(file, nrows = -1){
raw <- read.table(file, header=TRUE, nrow = nrows, sep="|", fill=TRUE, strip.white=TRUE)
num.rows <- dim(raw)[1]
raw$index <- 1:num.rows
raw <- subset(raw, index != 1 & index != num.rows)
raw
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment