getDetailedTimelines {CodeDepends} | R Documentation |
Compute and plot life cycle of variables in code
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
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 |
vars |
the variables of interest |
functions |
What type of functions should be included in the
timeline: |
x |
the |
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 |
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
Examples
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)