如何直接执行write.csv在R中转成tar.gz格式? [英] How to directly perform write.csv in R into tar.gz format?
本文介绍了如何直接执行write.csv在R中转成tar.gz格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个大的data.frame,我想写入一个压缩的CSV文件。有没有办法直接将数据写入CSV.TAR.GZ压缩文件,而不是执行write.csv / gzip步骤,以减少DISK访问?
I have a big data.frame that I want to write into a compressed CSV file. Is there any way to directly write the data into a CSV.TAR.GZ compressed file instead of performing write.csv/gzip steps in order to reduce DISK access?
谢谢。
推荐答案
使用 gzfile
(或 bzfile
用于bzip2归档,或 xzfile
用于xz归档)。
Use gzfile
(or bzfile
for bzip2 archiving, or xzfile
for xz archiving).
z <- gzfile("mtcars.csv.gz")
write.csv(mtcars, z)
PS。如果你只有一个数据框,肯定你不需要tar。
PS. If you only have one data frame, surely you don't need tar.
这篇关于如何直接执行write.csv在R中转成tar.gz格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文