[R] write.zip?

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Feb 10 09:14:02 CET 2010


On Tue, 9 Feb 2010, spencerg wrote:

>     Can one write a zip file from R? 
>
>     I want to create a file with a name like "dat.zip", being a zip file 
> containing "dat.csv".  I can create "dat.csv", then call "system('zip -r9 
> dat.zip dat.csv')".  Is there a better way?

Not really.  One could use compiled code like that in unzip() to do 
this, but as nothing inside R is involved the only gain would be to 
not need to have the zip executable present.  Omegahat package 
Rcompression does have means to manipulate .zip files from compiled 
code with an R interface, but not AFAICS a simpler way to do what you 
want.

>     I can use "gzfile" to write a gz file, but I don't know how to give that 
> a structure that would support unzipping to a *.csv file.

A zip file is not a gzipped file, even though gzip compression is used 
for parts of the contents.  The header and trailer are quite 
different.

>
>     Thanks,
>     Spencer 
> -- 
> Spencer Graves, PE, PhD
> President and Chief Operating Officer
> Structure Inspection and Monitoring, Inc.
> 751 Emerson Ct.
> San José, CA 95126
> ph:  408-655-4567
>
> ______________________________________________
> 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.
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


More information about the R-help mailing list