getDetailedTimelines: Compute and plot life cycle of variables in code

Description Usage Arguments Value Author(s) See Also Examples

View source: R/graph.R

Description

These functions allow one to get and visualize information about when variables are defined, redefined and used within and across blocks of code in a script or the body of a function.

Usage

1
2
3
4
5
6
getDetailedTimelines(doc, info = getInputs(doc, ...), vars =
getVariables(info, functions = functions), functions=TRUE, ...)
## S3 method for class 'DetailedVariableTimeline'
plot(x, var.srt = 0,
                                         var.mar = round(max(4,
.5*max(nchar(levels(x$var))))), var.cex = 1, main = attr(x, "scriptName"),...)

Arguments

doc

the name of a file or a connection which identifies the code to be analyzed

info

meta-information extracted from the code identifying the inputs and outputs. See getInputs.

vars

the variables of interest

functions

What type of functions should be included in the timeline: NULL for none, TRUE for locally defined only, NA for unknown provenance functions, or FALSE for non-locally-defined functions. Defaults to TRUE.

x

the DetailedVariableTimeline object being plotted

var.srt

rotation of the labels for the vertical axis listing the variables

var.mar

the number of lines to leave for the vertical axis. The labels for this are variable names so one often needs more space or to change the size of the labels.

var.cex

character expansion factor for the variable labels on

the vertical axis.

main

the title of the plot

...

Passed to down to getInputs for the default info value in getDetailedTimelines and to underlying plotting functions for plot.DetailedTimelines.

Value

getDetailedTimelines returns a data frame with four columns: step, used, defined, and var. Step represents steps within the timeline, with the same value indicating that the described event are occuring at the same time. used indicates whether var was used at that step, and defined indicates whether var was defined. Many rows will have FALSE for both as the variable is not used in that code block.

Author(s)

Duncan Temple Lang

See Also

getInputs

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
f = system.file("samples", "results-multi.R", package = "CodeDepends")
sc = readScript(f)
dtm = getDetailedTimelines(sc, getInputs(sc))
plot(dtm)
table(dtm$var)

 # A big/long function
info = getInputs(arima0)
dtm = getDetailedTimelines(info = info)
plot(dtm, var.cex = .7, mar = 4, srt = 30)

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