makeVariableGraph {CodeDepends}R Documentation

Create a graph describing the relationships between variables in a script

Description

This creates a graph of nodes and edges describing the relationship of how some variables are used in defining others.

Usage

makeVariableGraph(doc, frags = readScript(doc), info = getInputs(frags),
                   vars = getVariables(info, inputs = free), free = TRUE)

Arguments

doc

the name of the script file

frags

the code fragments from the script as a Script object.

info

the ScriptInfo list of ScriptNodeInfo objects describing each node.

vars

a character vector giving the names of the variables in the scripts. By default, these are the variables defined in the script.

free

a logical value that is passed to getInputs and controls whether we include the free/global variables in the script.

Details

Note that this collapses variables with the same name into a single node. Therefore, if the code uses the same name for two unrelated variables, there may be some confusion.

Value

An object of class graphNEL from the graph package.

Author(s)

Duncan Temple Lang

See Also

readScript getInputs getVariables

graph Rgraphviz

Examples

## Not run: 
 u = url("http://www.omegahat.net/CodeDepends/formula.R")
 sc = readScript(u)
 close(u)
 g = makeVariableGraph(, sc)

## End(Not run)

 f = system.file("samples", "results-multi.R", package = "CodeDepends")
 sc = readScript(f)
 g = makeVariableGraph( info = getInputs(sc))
 if(require(Rgraphviz))
   plot(g)

[Package CodeDepends version 0.6.6 Index]