R: Select Package Repositories (original) (raw)

setRepositories {utils} R Documentation

Description

Interact with the user to choose the package repositories to be used.

Usage

setRepositories(graphics = getOption("menu.graphics"),
                ind = NULL, addURLs = character(), name = NULL)

Arguments

graphics Logical. If true, use a graphical list: on Windows or macOS GUI use a list box, and on a Unix-alike if tcltk and an X server are available, use Tk widget. Otherwise use a textmenu.
ind NULL or a vector of integer indices, which have the same effect as if they were entered at the prompt forgraphics = FALSE.
name NULL or character vector of names of the repositories in the repository table which has the same effect as passing the corresponding indices to ind.
addURLs A character vector of additional URLs: it is often helpful to use a named vector.

Details

The default list of known repositories is stored in the file ‘R_HOME/etc/repositories’. That file can be edited for a site, or a user can have a personal copy in the file pointed to by the environment variableR_REPOSITORIES, or if this is unset, NULL or does not exist, in ‘HOME/.R/repositories’, which will take precedence.

A Bioconductor mirror can be selected by setting[options](../../base/html/options.html)("BioC_mirror"), e.g. via[chooseBioCmirror](../../utils/help/chooseBioCmirror.html) — the default value is ‘⁠"https://bioconductor.org"⁠’. This version of R chooses Bioconductor version 3.21 by default, but that can be changed via the environment variableR_BIOC_VERSION.

The items that are preselected are those that are currently inoptions("repos") plus those marked as default in the list of known repositories.

The list of repositories offered depends on the setting of option"pkgType" as some repositories only offer a subset of types (e.g., only source packages or not macOS binary packages). Further, for binary packages some repositories (notably R-Forge) only offer packages for the current or recent versions of R. (Type "both" is equivalent to "source".)

Repository ‘⁠CRAN⁠’ is treated specially: the value is taken from the current setting of getOption("repos") if this has an element "CRAN": this ensures mirror selection is sticky.

This function requires the R session to be interactive unlessind or name is supplied. The latter overrides the former if both are supplied and values are not case-sensitive. If any of the supplied names does not match, an error is raised.

Value

This function is invoked mainly for its side effect of updatingoptions("repos"). It returns (invisibly) the previousrepos options setting (as a [list](../../base/html/list.html) with componentrepos) or [NULL](../../base/html/NULL.html) if no changes were applied.

Note

This does not set the list of repositories at startup: to do so set [options](../../base/html/options.html)(repos =) in a start up file (see help topicStartup) or via a customized ‘repositories’ file.

See Also

[chooseCRANmirror](../../utils/help/chooseCRANmirror.html), [chooseBioCmirror](../../utils/help/chooseBioCmirror.html),[install.packages](../../utils/help/install.packages.html).

Examples

## Not run: 
setRepositories(addURLs =
                c(CRANxtras = "https://www.stats.ox.ac.uk/pub/RWin"))

## End(Not run)
oldrepos <- setRepositories(name = c("CRAN", "R-Forge"))
getOption("repos")
options(oldrepos) # restore

[Package _utils_ version 4.6.0 Index]