I have various .gz files kept in different folders. A sample of the order of files is mentioned below. I want to ungz them and want them to be in the same folder as before (e.g. .gz files of Folder 1a should be remain in Folder 1a upon ungz-ing) and delete the .gz files later.
Folder1
Folder 1a > many .gz files
Folder 2a > many .gz files
Folder 3a > many .gz files
.
.
.
I know how to unzip .zip files but that does not seem to work for .gz files. I want to do it in R, can anyone please help. I am working in Windows.
First write a function to decompress a single file. The
gzfile()function can be used to open a connection that decompresses a gzip file.Then, apply it to the files you want to decompress: