check_source | R Documentation |
Approximately detect global and imported functions or variables from R-scripts, folders or R-code strings by static code analysis. For inspection of individual R-scripts use the 'file' argument, for R-code strings use the 'text' argument, and for folders containing R-scripts use the 'dir' argument. This function does not require executing the code under inspection.
check_source(file, text, dir, include_compiled = FALSE, skip_globals = NULL)
file |
character path to R-script to analyze, can be either a file on the local filesystem or a remote file location (e.g. a server or the web). |
text |
character R-code string to analyze. |
dir |
character path to folder with R-scripts to analyze. |
include_compiled |
logical value indicating if compiled functions called with |
skip_globals |
optional character vector of names to skip/exclude as (unrecognized) global variables. |
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
.
checkglobals
, check_pkg
## local R-script
check_source(
file = system.file(
"unit_tests", "pkg", "testpkg", "R", "functions1.R",
package = "checkglobals"
)
)
## local R-folder
check_source(
dir = system.file(
"unit_tests", "pkg", "testpkg", "R",
package = "checkglobals"
)
)
## R-code string
check_source(text = "cc <- function(m) stats::coef(m)")
## R-script from remote location
check_source(
file = "https://raw.githubusercontent.com/rstudio/shiny-examples/main/004-mpg/app.R"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.