getPropagateChanges {CodeDepends}R Documentation

Determine which expressions to update when a variable changes

Description

This function allows us to determine which subsequent expressions in the document need to be evaluated when a variable is assigned a new value. This is the "opposite" of determining on which variables a given variable depends; this is for identifying which variables and expressions need to be updated when a variable changes. This is of use when propogating changes to dependent expressions.

Usage


getPropagateChanges(var, expressions, info = lapply(expressions,
                    getInputs), recursive = FALSE, index = FALSE, envir
                    = globalenv(), eval = !missing(envir), verbose =
                    FALSE)

Arguments

var

the name of the variable which has changed

expressions

the list of all expressions in the document

info

information extracted from the expressions about the inputs to each expressions. See getInputs.

recursive

a logical value that controls whether to work recursively on the expressions

index

a logical value which controls whether we return the indices of the expressions that would need to be evaluated based on the change to the variable var, or if index is FALSE, we return the expressions themselves.

envir

the environment in which to evaluate the expressions

eval

a logical value controlling whether we evaluate the expressions or just return them

verbose

a logical value that controls whether we output information about the expressions and their evaluation on the R console.

Value

This returns either the expressions or the indices of the expressions that need to be re-evaluated due to a change in var.

Note

The returned expression do NOT include the expression which defines the variable var. Only expressions *after* that are included.

Author(s)

Duncan Temple Lang

See Also

getExpressionThread getDependsThread

Examples

sc = readScript(system.file("samples", "formula.R", package = "CodeDepends"))
info = getInputs(sc)
getPropagateChanges("x", sc, info = info)
getPropagateChanges("y", sc, info = info)

[Package CodeDepends version 0.6.6 Index]