missingScriptVars: Find Definitions for Variables in Scripts

View source: R/scriptInfoFuns.R

missingScriptVarsR Documentation

Find Definitions for Variables in Scripts

Description

For a given script, this function identifies variables used but not previously defined in the script and then searches other scripts to find code that creates those variables.

Usage

missingScriptVars(script, dir = ".",
                  allScripts = list.files(dir, pattern = "\\.R$", full.names = TRUE),
                  varDefs = varDefsByFile(, allScripts),
                  unbox = TRUE)

Arguments

script

the paths to the file names containing the R code to be analyzed

dir

the directory in which to find the other scripts

allScripts

the full paths to all the scripts in which to look for variable definitions

varDefs

the pre-computed collection of variable definitions across all scripts.

unbox

a scalar logical that controls whether to keep the list structure for the return (FALSE) or return its first element corresponding to the single script.

Value

A list with the same length as script with an element corresponding to each element of script. Each element is a named list of character vectors. The names identify the variables found undefined but used in the script. The character vector gives the names of the files containing one or more definition for that variable.

If there is only one element in script and unbox is TRUE, that first element is returned directly, i.e., not a list of length 1 containing the element.

Author(s)

Duncan Temple Lang

See Also

getScriptGlobals


duncantl/CodeAnalysis documentation built on June 12, 2025, 6:44 a.m.