CodeDepends (version 0.6.5)

getVariableDepends: Determine dependencies for code blocks

Description

These functions provide ways to determine which code blocks must be evaluated before others based on input and output variables. getVariableDepends is used to determine the code blocks that need to be run in order to define particlar variables. getSectionDepends

Usage

getVariableDepends(vars, frags, info = lapply(frags, getInputs, ...),
checkLibraries = FALSE, asIndex = FALSE, functions = TRUE, ...)
getSectionDepends(sect, frags, info = lapply(frags, getInputs, ...), index =
FALSE, ...)

Arguments

vars

the names of the variables of interest

frags

the blocks or groups of expressions from the document

info

the information about the fragments that identify the inputs. This is typically computed as the default value for the parameter but can be provided explicitly when the caller has alreay computed this and passes it to different functions.

index

a logical value that controls whether we return the indices of the fragments of interest (TRUE) or return the fragments themselves (FALSE)

sect

the index of the section/fragment to be analyzed

checkLibraries

a logical value

asIndex

a logical value that controls whether we return the expressions/code blocks or their indices.

functions

passed to getVariables. What kind of functions should be counted as variables (TRUE is local functions only, the default)

...

passed to getInputs. Ignored if info is explicitly specified.

Value

getVariableDepends returns a Script-class object consisting of the subset of code blocks relevant to the specified variables.

If asIndex is TRUE, getVariableDepends returns the indices of the code blocks in the original script.

See Also

getPropagateChanges getExpressionThread

Examples

Run this code
# NOT RUN {
e = readScript(system.file("samples", "dual.R", package = "CodeDepends"))
getVariableDepends("fit", e, formulaInputs = TRUE)
getVariableDepends("fit", e, formulaInputs = TRUE, asIndex = TRUE)

getVariableDepends("y", e, asIndex = TRUE)
getVariableDepends("y", e)

# }

Run the code above in your browser using DataCamp Workspace