Decompress gz file using R

后端 未结 5 1193
逝去的感伤
逝去的感伤 2020-11-27 04:52

I have used ?unzip in the past to get at contents of a zipped file using R. This time around, I am having a hard time extracting the files from a .gz file whic

5条回答
  •  星月不相逢
    2020-11-27 05:20

    http://blog.revolutionanalytics.com/2009/12/r-tip-save-time-and-space-by-compressing-data-files.html

    R added transparent decompression for certain kinds of compressed files in the latest version (2.10). If you have your files compressed with bzip2, xvz, or gzip they can be read into R as if they are plain text files. You should have the proper filename extensions.

    The command...

    myData <- read.table('myFile.gz')  
    

    #gzip compressed files have a "gz" extension

    Will work just as if 'myFile.gz' were the raw text file.

提交回复
热议问题