makeVariableGraph

0th

Percentile

Create a graph describing the relationships between variables in a script

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

Keywords
hplot, programming
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.

See Also

readScript getInputs getVariables

graph Rgraphviz

Aliases
  • makeVariableGraph
Examples
# NOT RUN {
 u = url("http://www.omegahat.net/CodeDepends/formula.R")
 sc = readScript(u)
 close(u)
 g = makeVariableGraph(, sc)
# }
# NOT RUN {
 f = system.file("samples", "results-multi.R", package = "CodeDepends")
 sc = readScript(f)
 g = makeVariableGraph( info = getInputs(sc))
 if(require(Rgraphviz))
   plot(g)
# }
Documentation reproduced from package CodeDepends, version 0.6.5, License: GPL

Community examples

Looks like there are no examples yet.