p_inst: Immediate or delayed package installation

p_instR Documentation

Immediate or delayed package installation

Description

p_inst is a wrapper around install.packages. It tries hard to select the most appropriate lib and stops in case of conflict. Use install.packages if any additional argument is needed.

p_inst_batsh writes one executable file .sh (Linux, macOS) or two files .bat, .R (Windows) that allow a delayed installation of old packages in a R –vanilla environment. This is useful if the default configuration of R defined in R/etc/Rprofile.site launchs additional packages with compiled code, since these packages cannot be updated without modifying the R/etc/Rprofile.site file.

p_oldpkgs is a wrapper around old.packages.

For the three above functions, if crandb loaded in .GlobalEnv, then the packages are sorted by their increasing number of dependencies.

... allows a non-standard evaluation of unquoted packages separated by commas.

Usage

p_inst(..., char = NULL, lib = NULL, repos = getOption("repos")[1],
  contriburl = NULL, dependencies = NA, type = getOption("pkgType"))

p_oldpkgs(type = "both", lib.loc = .libPaths()[1],
  repos = getOption("repos")[1])

p_inst_batsh(..., char = NULL, type = "binary", verbose = TRUE,
  dir = ".", lib = .libPaths()[1], repos = getOption("repos")[1])

Arguments

...

any format recognized by cnsc, excluding list. A vector of packages.

char

(name to) a character vector or a list. Use this argument if ... fails or if you call the function from another function. If used, argument ... is ignored.

lib

character. The directory where to install the packages, usually one of the directories listed by .libPaths. If NULL, select automatically the most relevant directory.

repos

character. The address of your local CRAN.

contriburl

character. The address of your private repository.

dependencies

logical. FALSE skips the installation of dependencies. NA installs c("Depends", "Imports", "LinkingTo") dependencies.

type

character. Either "source", "both", "binary" (or its variants "mac.binary", "mac.binary.el-capitan", "win.binary").

lib.loc

character. The directory where to search for old packages.

verbose

Logical. Print information of the download process.

dir

character. The directory where to write the files .sh, .bat, .R.

Examples

tmpdir <- tempdir()
pkgs <- p_oldpkgs(type = "source", repos = "https://cloud.r-project.org")
pkgs <- c("brew","fs","XML","RWsearch")
p_inst_batsh(pkgs, type = "source", dir = tmpdir, repos = "https://cloud.r-project.org")
if (.Platform$OS.type == "windows") {
    unlink(file.path(tmpdir, "installrpkgs.R"))
    unlink(file.path(tmpdir, "installrpkgs.bat")) 
} else unlink(file.path(tmpdir, "installrpkgs.sh"))


RWsearch documentation built on April 3, 2025, 11:36 p.m.