sourceVariable

0th

Percentile

Evaluate code in document in order to define the specified variables

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.

Keywords
programming
Usage
sourceVariable(vars, doc, frags = readScript(doc), eval = TRUE, env = globalenv(), 
                nestedEnvironments = FALSE, verbose = TRUE,
                 checkLibraries = eval, force = FALSE, first = FALSE,
                  info = lapply(frags, getInputs))
Arguments
vars

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.

doc

the document containing the code blocks

frags

the code fragments

eval

whether to evaluate the necessary code blocks or just return them.

env

the environment in which to evaluate the code blocks.

nestedEnvironments

a logical value indicating whether to evaluate each of the different code blocks within their own environment that is chained to the previous one.

verbose

a logical value indicating whether to print the expression being evaluated before it is actually evaluated.

checkLibraries

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.

force

a logical value that controls whether we evaluate the expressions if they variables appear to exist.

first

a logical value. This is intended to allow running up to the first instance of the variable, not all of them.

info

the information about each expression. This is computed automatically, but the caller can specify it to avoid redundant computations.

Value

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

Note

We should add a nestedEnvironments parameter as in runUpToSection. In fact, consolidate the code so it can be shared.

See Also

getVariableDepends

Aliases
  • sourceVariable
Examples
# NOT RUN {
 f = system.file("samples", "dual.R", package = "CodeDepends")
 e = readScript(f)
 getVariableDepends("k", frags = e)
 sourceVariable("k", frags = e, verbose = TRUE)
# }
Documentation reproduced from package CodeDepends, version 0.6.5, License: GPL

Community examples

Looks like there are no examples yet.