R Language Extract all .zip archives in a directory


Example

With a simple for loop, all zip archives in a directory can be extracted.

for (i in dir(pattern=".zip$"))
    unzip(i)

The dir function produces a character vector of the names of the files in a directory matching the regex pattern specified by pattern. This vector is looped through with index i, using the unzip function to extract each zip archive.