Check for allowed or disallowed package dependencies within a project or directory using pak::scan_deps().
Source: R/check_pkgs.R
check_pkgs.RdCheck for allowed or disallowed package dependencies within a project or directory using pak::scan_deps().
Usage
installed_pkgs()
missing_pkgs(
dir = here::here(),
regexp = "[.](R|r|Rmd|rmd|Rnw|rnw|Qmd|qmd)$",
recurse = TRUE
)
install_missing_pkgs(
dir = here::here(),
regexp = "[.](R|r|Rmd|rmd|Rnw|rnw|Qmd|qmd)$",
recurse = TRUE,
...
)
update_installed_pkgs()
find_pkgs(
dir = here::here(),
regexp = "[.](R|r|Rmd|rmd|Rnw|rnw|Qmd|qmd)$",
full = FALSE,
recurse = TRUE
)
check_allowed_pkgs(
pkgs,
dir = here::here(),
regexp = "[.](R|r|Rmd|rmd|Rnw|rnw|Qmd|qmd)$",
recurse = TRUE
)
check_disallowed_pkgs(
pkgs,
dir = here::here(),
regexp = "[.](R|r|Rmd|rmd|Rnw|rnw|Qmd|qmd)$",
recurse = TRUE
)
check_required_pkgs(
pkgs,
dir = here::here(),
regexp = "[.](R|r|Rmd|rmd|Rnw|rnw|Qmd|qmd)$",
recurse = TRUE
)Arguments
- dir
Directory to search.
- regexp
Regular expression used to select files, defaults to matching
R,Rmd,Rnw, andqmdfiles (and their case variants).- recurse
Should directory be recursively explored (i.e. match files in subdirectories)
- ...
Additional arguments passed to
install.packages().- full
Should the full data frame of dependencies be returned or just a vector of package names.
- pkgs
Character vector of package names
Value
installed_pkgs(), missing_pkgs(), and find_pkgs() return a
character vector of package names (find_pkgs() returns a data frame of
dependency details when full = TRUE). install_missing_pkgs() and
update_installed_pkgs() are called for their side effect of installing
or updating packages and return NULL or the result of
pak::pkg_install() invisibly. The check_* functions return TRUE or
FALSE invisibly, indicating whether the check passed.
Functions
installed_pkgs(): Returns a vector of installed packages.missing_pkgs(): Returns a vector of packages found byfind_pkgsthat are not currently installed.install_missing_pkgs(): Installs missing packages found bymissing_pkgs.update_installed_pkgs(): Updates installed packages usingpak::pkg_install(). Packages installed from a remote such as GitHub are updated from that same source, others are updated from the configured repositories. Packages that are not available from a repository and were not installed from a remote (e.g. packages installed from a local source tarball) are skipped, provided the repository index can be retrieved viautils::available.packages().find_pkgs(): Find all of the packages used within a project usingpak::scan_deps().check_allowed_pkgs(): Check that only the allowed packages are usedcheck_disallowed_pkgs(): Check if any disallowed packages are usedcheck_required_pkgs(): Check that the required packages are used
Examples
if (FALSE) { # \dontrun{
dir = system.file("examples/package", package = "checklist")
find_pkgs(dir)
missing_pkgs(dir)
check_allowed_pkgs(c("dplyr", "ggplot2"), dir)
check_disallowed_pkgs("nlme", dir)
check_required_pkgs("dplyr", dir)
} # }