Hand-crafting an .RData file
You can try read.csv.sql in the sqldf package. It reads a file into an sqlite database which it creates for you using RSQLite/sqlite thus effectively its done outside of R. Then it extracts the portion you specify using an sql statement and destroys the database. Omit the sql statement if you want the entire file. Don't know if its faster than read.table when used in that way but its only one line of code so you could easily try it. See example 13 on home page: http://sqldf.googlecode.com
On Mon, Nov 9, 2009 at 12:27 AM, Adam D. I. Kramer <adik at ilovebacon.org> wrote:
Hello,
? ? ? ?I frequently have to export a large quantity of data from some
source (for example, a database, or a hand-written perl script) and then
read it into R. ?This occasionally takes a lot of time; I'm usually using
read.table("filename",comment.char="",quote="") to read the data once it is
written to disk.
? ? ? ?However, I *know* that the program that generates the data is more
or less just calling printf in a for loop to create the csv or tab-delimited
file, writing, then having R parse it, which is pretty inefficient. Instead,
I am interested in figuring out how to write the data in .RData
format so that I can load() it instead of read.table() it.
? ? ? ?Trolling the internet, however, has not suggested anything about the
specification for an .RData file. Could somebody link me to a specification
or some information that would instruct me on how to construct a .RData
file (either compressed or uncompressed)?
? ? ? ?Also, I am open to other suggestions of how to get load()-like
efficiency in some other way.
Many thanks,
Adam D. I. Kramer
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.