Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R directly save data as zip file [duplicate]

Tags:

r

compression

zip

I found zip and the RCompression package but can they do:

write.zip(x, file = "foo.zip")

as you'd with write.csv?

I'm also aware of gzfile.

like image 212
Rico Avatar asked Jul 08 '13 18:07

Rico


People also ask

How do I zip a data file in R?

To zip files in R, use the zip() function. The zipped file is stored inside the current directory unless a different path is specified in the zip() function argument. The zip() method creates a new ZIP archive, and it overwrites the output file if it exists.

How do I zip a file twice?

Hold down [Ctrl] on your keyboard > Click on each file you wish to combine into a zipped file. Right-click and select "Send To" > Choose "Compressed (Zipped) Folder."

How do I zip a csv file in R?

The zip = "C:\\Program Files\\7-Zip\\7Z" argument tells R what program to use perform the compression. In this case, I pointed it at 7Z, the command line version of 7Zip, but you can use other command line programs by changing this to point to a different program.

Is copying a zip file faster?

That makes the transfer of multiple files an onerous and time-consuming task. Because transferring a single file is always faster than multiple files, the ZIP format is a handy tool for improving overall file transfer turnaround time through fast file consolidation.


1 Answers

It's possible using gzip.

write.csv(mtcars, file=gzfile("mtcars.csv.gz"))
like image 193
Ven Yao Avatar answered Sep 27 '22 17:09

Ven Yao