A utility to check whether CRAN / GitHub / Bioconductor packages are installed,
with optional auto-installation via inst_pkg()
.
Usage
check_pkg(
pkg = NULL,
source = c("CRAN", "GitHub", "Bioconductor"),
auto_install = TRUE,
...
)
Arguments
- pkg
Character vector of package names or GitHub repos (e.g., "r-lib/devtools").
- source
Package source: one of "CRAN", "GitHub", "Bioconductor". Case-insensitive.
- auto_install
Logical. If TRUE (default), install missing packages automatically.
- ...
Additional arguments passed to
inst_pkg()
.
Examples
check_pkg("ggplot2", source = "CRAN")
#> ✔ Installed: ggplot2
#> # A tibble: 1 × 4
#> package name installed source
#> <chr> <chr> <lgl> <chr>
#> 1 ggplot2 ggplot2 TRUE CRAN
check_pkg("r-lib/devtools", source = "GitHub", auto_install = FALSE)
#> ✔ Installed: devtools
#> # A tibble: 1 × 4
#> package name installed source
#> <chr> <chr> <lgl> <chr>
#> 1 r-lib/devtools devtools TRUE GitHub