This function efficiently checks for the presence of a package without installing it (unlike library() or require(). This is useful to force yourself to use the package::function syntax for addressing functions; you can make sure required packages are installed, but their namespace won't attach to the search path.

  install = FALSE,
  load = FALSE,
  repos = ""



A vector with packages. If this is a names vector, the names are the package names, and the values are the minimum required package versions.


Whether to install missing packages from repos.


Whether to load packages (which is exactly not the point of this package, but hey, YMMV).


The repository to use if installing packages; default is the RStudio repository.


Invisibly, a vector of the available packages.


checkPkgs('base'); ### This will show the error message tryCatch( checkPkgs(base = "99"), error = print );
#> <simpleError in checkPkgs(base = "99"): Of package(s) 'base', you need at least versions 99, respectively. Install those with: #> #> install.packages(c('base')); #> >