Install packages required for the full camtrapReport workflow, including packages used by optional report modules.
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 the packages
declared
by the currently available YAML report modules, including modules added or
modified by users, and combines them with any additional packages supplied
through pkgs. 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)]
#> character(0)
# Package installation changes the user's R library, so these examples are
# deliberately restricted to interactive sessions.
if (interactive()) {
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)
}