View source: R/check_package.R
check_package | R Documentation |
Check if a package is installed and if it is installed, check if the version is equal to or higher than the required version or check if a package is attached.
check_package(x, version = NULL, type = "installed")
assert_package(
x,
version = NULL,
type = "installed",
.var.name = checkmate::vname(x),
comment = NULL,
add = NULL
)
x |
[ |
version |
[character(1)] |
type |
[character(1)]
|
.var.name |
[ |
comment |
[ |
add |
[ |
Depending on the function prefix:
If the check is successful, the function
assert_package
return x
invisibly, whereas
check_package
return TRUE
.
If the check is not successful,
assert_package
throws an error message and
check_package
returns a string with the error message.
# returns TRUE i.e. no error message
check_package(x = "checkmate", version = "2.0.0", type = "installed")
# returns an error message
check_package(x = "nopackage", type = "installed")
check_package(x = "nopackage", type = "attached")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.