This function allows the caller to evaluate the code within the
document (or list of code chunks directly) in order to define
one or more variables and then terminate. This is similar
to runUpToSection
but is oriented towards variables
rather than particular code blocks.
sourceVariable(vars, doc, frags = readScript(doc), eval = TRUE, env = globalenv(),
nestedEnvironments = FALSE, verbose = TRUE,
checkLibraries = eval, force = FALSE, first = FALSE,
info = lapply(frags, getInputs))
If eval
is TRUE
, a list of the results
of evaluating the code blocks. Alternatively,
if eval
is FALSE
, this returns the expressions
constituting the code blocks. In this case, the function is the same
as getVariableDepends
the names of the variables which are of interest. This need not include intermediate variables, but instead is the vector of names of the variables that the caller wants defined ultimately.
the document containing the code blocks
the code fragments
whether to evaluate the necessary code blocks or just return them.
the environment in which to evaluate the code blocks.
a logical value indicating whether to evaluate each of the different code blocks within their own environment that is chained to the previous one.
a logical value indicating whether to print the expression being evaluated before it is actually evaluated.
a logical value that controls whether we check
for functions that are not currently available and if there are any
whether we add calls to load libraries in getVariableDepends
.
a logical value that controls whether we evaluate the expressions if they variables appear to exist.
a logical value. This is intended to allow running up to the first instance of the variable, not all of them.
the information about each expression. This is computed automatically, but the caller can specify it to avoid redundant computations.
Duncan Temple Lang
getVariableDepends
f = system.file("samples", "dual.R", package = "CodeDepends")
e = readScript(f)
getVariableDepends("k", frags = e)
sourceVariable("k", frags = e, verbose = TRUE)
Run the code above in your browser using DataLab