Install packages in camtrapReport's module inventory and additional packages
requested through pkgs.
Usage
install_all(pkgs = NULL, update = FALSE, github = TRUE,
gitlab = FALSE, ...)
# S4 method for class 'ANY'
install_all(pkgs = NULL, update = FALSE, github = TRUE, gitlab = FALSE, ...)Arguments
- pkgs
An optional character vector of additional package names. The default is
NULL.- update
A logical value. If
TRUE, optional packages are force-reinstalled. The default isFALSE.- github
A logical value (default
TRUE) specifying whether packages configured in GitHub repositories are included.- gitlab
A logical value (default
FALSE) specifying whether packages configured in GitLab repositories are included.- ...
Additional named arguments passed to
pak::pkg_install(), such aslib,ask,dependencies, orupgrade.
Details
The function checks the package list used by camtrapReport and installs
packages that are not currently available. Packages configured as GitHub
or GitLab dependencies are installed from their corresponding repositories.
All package installation is handled by pak::pkg_install().
Unlike a direct call to pak, install_all() discovers package declarations
in the installed report-module pool and any packaged configuration inventory.
It does not inspect a project's copied module registry or an object's
selected
profile. Supply custom-module and other optional analytical requirements
explicitly through pkgs; these are added to, not substituted for, the
discovered inventory. It then delegates resolution and installation to pak.
The function is opt-in and is never called when the package is loaded or a
report is rendered.
install_All() is retained as a deprecated compatibility alias. New code
should use install_all().
To inspect optional packages without installing anything, examine module
YAML #| packages: declarations (see the module guide). Use
pkgs[!vapply(pkgs, requireNamespace, logical(1), quietly = TRUE)] to check
a character vector of package names. There is currently no dry_run
argument; passing that name through ... is not a supported inspection API.
When update = TRUE, the requested optional packages are force-reinstalled
from their configured sources using the pak reinstall parameter.
Dependencies are upgraded only when required by the requested packages,
unless upgrade = TRUE is supplied through ....
Examples
# Inspect one module's optional packages without installing anything.
module_file <- system.file(
"reportSections", "sampling.yml", package = "camtrapReport"
)
declaration <- grep(
"#| packages:", readLines(module_file, warn = FALSE),
value = TRUE, fixed = TRUE
)
pkgs <- trimws(strsplit(
sub("#| packages:", "", declaration, fixed = TRUE), ","
)[[1]])
pkgs[!vapply(pkgs, requireNamespace, logical(1), quietly = TRUE)]
#> [1] "gt"
# Package installation changes the user's R library, so these examples are
# enabled only by a deliberate environment-variable opt-in.
if (interactive() && identical(Sys.getenv("CAMTRAPREPORT_INSTALL_EXAMPLE"), "true")) {
install_all()
install_all(pkgs = "readr")
install_all(update = TRUE)
# Reinstall the requested packages and also update their dependencies.
install_all(update = TRUE, upgrade = TRUE)
}
