CodeDepends (version 0.6.5)

getDependsThread: Compute which code blocks in a script are inputs to define a variable

Description

This function is used to determine which code blocks in an R "script" that are needed to define a particular variable. This finds the smallest complete set of expressions or code blocks that must be evaluated in order to define the specified variable(s). It omits expressions that do not provide outputs that are not used as inputs to (indirectly) define the speciied variable.

Usage

getDependsThread(var, info, reverse = TRUE)

Arguments

var

the name of a variable in the script

info

a list of the meta-information for each of the code elements in the script.

reverse

a logical value that determines whether we reverse the indices of the expressions or leave them as end-to-first.

Value

An integer vector giving the indices of the script code blocks which are required to define var.

See Also

getExpressionThread readScript getVariables

Examples

Run this code
# NOT RUN {
 sc = readScript(system.file("samples", "dual.R", package =
"CodeDepends"))
sci = getInputs(sc, formulaInputs = TRUE) ## script has formula with no data.frame
 idx = getDependsThread("fit", sci)
# }

Run the code above in your browser using DataCamp Workspace