checkglobals {checkglobals} | R Documentation |
Check R-source code or R-packages for globals and imports
Description
Approximately detect global and imported functions or variables from R-scripts, folders,
R-code strings or R-packages by static code analysis. This function is simply a convenience
wrapper around check_source
and check_pkg
and the return
value is the same as calling these functions directly. If called without a file
, dir
,
text
or pkg
argument, the function is run in the current working directory.
If the current working directory is an R-package folder, this is identical to checkglobals(pkg = ".")
,
otherwise the behavior is the same as checkglobals(dir = ".")
.
Usage
checkglobals(..., include_compiled = FALSE, skip_globals = NULL)
Arguments
... |
can be any one of the following arguments:
|
include_compiled |
logical value indicating if compiled functions called with |
skip_globals |
optional character vector of names to skip/exclude as (unrecognized) global variables. |
Value
list S3-object of class "checkglobals"
with three components:
-
globals
, list of class"checkglobalsg"
-
imports
, list of class"checkglobalsi"
-
missing_packages
, character vector with missing packages
for programmatic use, cast the returned S3-object with as.data.frame
, as.matrix
,
as.character
or as_vector
.
See Also
Examples
## local R-script
checkglobals(
file = system.file(
"unit_tests", "pkg", "testpkg", "R", "functions1.R",
package = "checkglobals"
)
)
## local R-folder
checkglobals(
dir = system.file(
"unit_tests", "pkg", "testpkg", "R",
package = "checkglobals")
)
## R-code string
checkglobals(text = "cc <- function(m) stats::coef(m)")
## R-package from folder
checkglobals(
pkg = system.file(
"unit_tests", "pkg", "testpkg",
package = "checkglobals"
)
)
## R-script from remote location
checkglobals(
file = "https://raw.githubusercontent.com/rstudio/shiny-examples/main/004-mpg/app.R"
)
## R-package from remote location
check_pkg(
pkg = "https://cran.r-project.org/src/contrib/tinytest_1.4.1.tar.gz",
skip_globals = "cluster"
)