Help you to check if you have certain packages and return missing package names

checkNameSpace(
  packages,
  quietly = FALSE,
  from = "CRAN",
  time_out = 1,
  on_timeout = {     FALSE }
)

Arguments

packages

vector of strings

quietly

bool, give you warning on fail?

from

string, where this package is from like, "CRAN", "GitHub", only for output message display purpose

time_out

numeric, how long to wait before reaching the time limit. Sometimes there are too many pkgs installed and takes too long to scan the whole list. Set this timeout in seconds to prevent the long waiting.

on_timeout

expressions, call back experssions to run when reaches timeout time. Default is return FALSE as indicating that package is missing (we can't find the package).

Value

vector of strings, of missing package names, character(0) if no missing

Examples

checkNameSpace("ggplot2")
#> Warning: 
[WARNING] 2021-10-30 02:04:07 These packages are missing from CRAN: ggplot2
#> [1] "ggplot2"
checkNameSpace("random_pkg")
#> Warning: 
[WARNING] 2021-10-30 02:04:07 These packages are missing from CRAN: random_pkg
#> [1] "random_pkg"
checkNameSpace("random_pkg", quietly = TRUE)
#> [1] "random_pkg"