Skip to content

Instantly share code, notes, and snippets.

@igrep
Created October 11, 2010 17:17
Show Gist options
  • Save igrep/620883 to your computer and use it in GitHub Desktop.
Save igrep/620883 to your computer and use it in GitHub Desktop.
Snapshot your R objects on a TSV.
#!/usr/bin/r
TSVSNAP.FILE = paste("snap/", Sys.Date(),".tsv", sep="")
tsvsnap = function(obj, ...){
UseMethod("tsvsnap")
}
tsvsnap.summary.lm = function(obj) tsvsnap.table( as.table( coefficients( obj ) ) )
tsvsnap.table = function(obj){
cat("", colnames(obj), file=TSVSNAP.FILE, sep="\t", append=TRUE, "\n")
rows = rownames(obj)
row.num = length(rows)
for( x in 1:row.num ){
cat(rows[x], obj[x,], file=TSVSNAP.FILE, sep="\t", append=TRUE, "\n")
}
cat("\n",file=TSVSNAP.FILE, append=TRUE)
}
tsvsnap.default = function(obj) cat(obj, file=TSVSNAP.FILE, sep="\t", append=TRUE,"\n\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment