download.packages {utils} | R Documentation

## Download Packages from CRAN-like Repositories

### Description

These functions can be used to automatically compare the version numbers of installed packages with the newest available version on the repositories and update outdated packages on the fly.

### Usage

    download.packages(pkgs, destdir, available = NULL,
                      repos = getOption("repos"),
                      contriburl = contrib.url(repos, type),
                      method, type = getOption("pkgType"), ...)

### Arguments

`pkgs` | character vector of the names of packages whose latest available versions should be downloaded from the repositories.
`destdir` | directory where downloaded packages are to be stored.
`available` | an object as returned by `available.packages` listing packages available at the repositories, or `NULL` which makes an internal call to `available.packages`.
`repos` | character vector, the base URL(s) of the repositories to use, i.e., the URL of the CRAN master such as `"https://cran.r-project.org"` or its Statlib mirror, `"http://lib.stat.cmu.edu/R/CRAN"`.
`contriburl` | URL(s) of the contrib sections of the repositories. Use this argument only if your repository mirror is incomplete, e.g., because you burned only the ‘contrib’ section on a CD. Overrides argument `repos`.
`method` | Download method, see `download.file`.
`type` | character string, indicate which type of packages: see `install.packages`.
`...` | additional arguments to be passed to `download.file`.

### Details

`download.packages` takes a list of package names and a destination directory, downloads the newest versions and saves them in `destdir`. If the list of available packages is not given as argument, it is obtained from repositories. If a repository is local, i.e. the URL starts with `"file:"`, then the packages are not downloaded but used directly. Both `"file:"` and `"file:///"` are allowed as prefixes to a file path. Use the latter only for URLs: see `url` for their interpretation. (Other forms of file:// URLs are not supported.)

### Value

A two-column matrix of names and destination file names of those packages successfully downloaded. If packages are not available or there is a problem with the download, suitable warnings are given.

### See Also

`available.packages`, `contrib.url`.

The main use is by `install.packages`.

See `download.file` for how to handle proxies and other options to monitor file transfers.

The ‘R Installation and Administration’ manual for how to set up a repository.

[Package utils version 3.4.2 Index]