[R] write.zip?

Duncan Temple Lang duncan at wald.ucdavis.edu
Wed Feb 10 20:57:50 CET 2010


Hi Spencer

  I just put a new source version (0.9-0) of the Rcompression package
on the www.omegahat.org/R  repository and it has a new function zip()
that creates or appends to a zip file, allowing one to provide
alternative names.

I'll add support for writing content from memory (i.e. AsIs
character strings and raw vectors) soon.

It doesn't yet handle replacing or removing elements yet.
I may use a different approach (e.g. the 7-zip lzma SDK)
to that and other things.

   D.

spencerg wrote:
> Thanks to Dieter Menne and Prof. Ripley for replies.
> 
>      For certain definitions of "better" (e.g., transportability?), the
> Rcompression package might be superior to the system call I mentioned. 
> I also just found the "tar" function in the "utils" package, which looks
> like it might be more transportable than my system call.
> 
>      However, as Prof. Ripley noted, there may not be a "simpler" way
> than my system call, especially considering the time I would have to
> invest to learn how to use it.
> 
>      Thanks again very much,
>      Spencer Graves
> 
> 
> Prof Brian Ripley wrote:
>> 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



More information about the R-help mailing list