check_pkg_installed {jamba} | R Documentation |
Lightweight method to check if an R package is installed
Description
Lightweight method to check if an R package is installed
Usage
check_pkg_installed(x, useMethod = c("packagedir", "requireNamespace"), ...)
Arguments
x |
|
useMethod |
|
... |
additional arguments are ignored. |
Details
There are many methods to test for an installed package.
Most approaches incur some time or resource penalty, so
check_pkg_installed()
is motivated for rapid results without
loading the package namespace.
This function also accepts multiple values for x
for convenience.
There are two available methods defined by useMethod
:
-
useMethod="packagedir"
confirms: this function represents possibly the most gentle and rapid approach. It simply callssystem.file(package=x)
, for each entry ofx
, then checks these requirements:Does the package directory exist via
system.file(package=x)
Does the package directory contain the file 'DESCRIPTION'?
It does not check whether the package can be loaded into the current R session.
-
useMethod="requireNamespace"
confirms:-
requireNamespace(x, quietly=TRUE)
returns TRUE It therefore loads the package namespace to confirm, but does not attach the package to the current session. It therefore may take time and resources, despite not altering the R environment search path.
-
The default behavior first tests by "packagedir", then
for any FALSE
results it also tests "requireNamespace"
.
Value
logical
vector indicating whether each value in x
represents an installed R package. The vector is named by
packages provided in x
.
See Also
Other jam practical functions:
breakDensity()
,
call_fn_ellipsis()
,
checkLightMode()
,
colNum2excelName()
,
color_dither()
,
exp2signed()
,
getAxisLabel()
,
isFALSEV()
,
isTRUEV()
,
jargs()
,
kable_coloring()
,
lldf()
,
log2signed()
,
middle()
,
minorLogTicks()
,
newestFile()
,
printDebug()
,
reload_rmarkdown_cache()
,
renameColumn()
,
rmInfinite()
,
rmNA()
,
rmNAs()
,
rmNULL()
,
setPrompt()
Examples
check_pkg_installed("methods")
check_pkg_installed(c("jamba",
"multienrichjam",
"venndir",
"methods",
"blah"))