R: Compress Files into 'zip' Archives

zip {zip} | R Documentation

## Compress Files into 'zip' Archives

### Description

`zip` creates a new zip archive file.

### Usage

    zip(zipfile, files, recurse = TRUE, compression_level = 9)

    zip_append(zipfile, files, recurse = TRUE, compression_level = 9)

### Arguments

`zipfile` | The zip file to create. If the file exists, `zip` overwrites it, but `zip_append` appends to it.
`files` | List of file to add to the archive. Absolute path names will be added as absolute path names, relative path names stay relative in the archive.
`recurse` | Whether to add the contents of directories recursively.
`compression_level` | A number between 1 and 9. 9 compresses best, but it also takes the longest.

### Details

`zip_append` appends compressed files to an existing 'zip' file.

### Value

The name of the created zip file, invisibly.

### Examples

    ## Some files to zip up
    dir.create(tmp <- tempfile())
    cat("first file", file = file.path(tmp, "file1"))
    cat("second file", file = file.path(tmp, "file2"))

    zipfile <- tempfile(fileext = ".zip")
    zip(zipfile, tmp)

    ## List contents
    zip_list(zipfile)

    ## Add another file
    cat("third file", file = file.path(tmp, "file3"))
    zip_append(zipfile, file.path(tmp, "file3"))
    zip_list(zipfile)

[Package zip version 1.0.0 Index]