[R] Zipping Rdata Files
Brian.J.GREGOR@odot.state.or.us
Brian.J.GREGOR at odot.state.or.us
Thu Apr 7 23:31:36 CEST 2005
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 at odot.state.or.us
(503) 986-4120
More information about the R-help
mailing list