makeGraph: Create a graph describing the relationships between variables...

Description Usage Arguments Details Value Author(s) See Also Examples

Description

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

Usage

1
2
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## 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)

CodeDepends documentation built on May 2, 2019, 4:19 a.m.