[R] Zipping Rdata Files

From: <Brian.J.GREGOR_at_odot.state.or.us>
Date: Fri 08 Apr 2005 - 07:31:36 EST


Saving Rdata files in a zip archive form can in some cases save a considerable amount of disk space. R has the zip.file.extract function to extract files from zip archives, but appears not to have any corresponding function to save in zipped form. (At least I have not been able to find anything in the help files or through searching the mail archives.) The system function can be used to call gzip or some other utility, but perhaps there is a more direct method.

Also, when I use gzip to zip a file, I get an error message when using zip.file.extract to extract the file as follows:

> save(trips, file="trips.Rdata")
> system("gzip trips.Rdata") # saves trips.Rdata in an archive

named trips.Rdata.gz

> load(zip.file.extract("trips.Rdata", "trips.Rdata.gz"))
[1] "trips.Rdata" Warning message: error 1 in extracting from zip file

Setting options(unzip="gunzip") or options(unzip="gunzip.exe") does not solve the error.

> load(zip.file.extract("trips.Rdata", "trips.Rdata.gz"))

	Error in open.connection(con, "rb") : unable to open connection
	In addition: Warning message: 
	cannot open compressed file `trips.Rdata' 

Of course I could reverse the process with,
	system("gunzip trips.Rdata.gz")
	load("trips.Rdata")

but perhaps there is a simpler solution.

P.S. I'm running R 2.0.1 on a Windows XP computer.

Brian Gregor, P.E.
Transportation Planning Analysis Unit
Oregon Department of Transportation
Brian.J.GREGOR@odot.state.or.us
(503) 986-4120



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Apr 08 07:39:34 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:04 EST