# getInputs

0th

Percentile

##### Get input and output variables and literals from R expressions

This function is used to analyze an R expression and identify the input and output variables in the expressions and related packages that are loaded and files that are referenced.

This might be better called getCodeDepends. It is not to be confused with getVariableInputs.

Keywords
programming
##### Usage
getInputs (e, collector = inputCollector(), basedir = ".", reset =
FALSE, formulaInputs = FALSE, ...)
##### Arguments
e

the expression whose code we are to process

collector

an object which collects the different elements of interest in the code.

basedir

the directory for the code relative to which we can resolve file names.

reset

a logical value that controls whether we call the collector's reset method before starting to process the expressions in the script.

formulaInputs

Logical indicating whether symbols appearing in formulas should be treated as inputs to the expression. Defaults to FALSE.

##### Value

A ScriptInfo object containing information about the expression(s) in e.

Things tracked include:

files

the names of any strings used as arguments or literal values that correspond to file names.

strings

A vector of literal strings which appeared in e

libraries

the names of any libraries explicitly loaded within this code.

inputs

a character vector naming the variables that are used as inputs to the computations in this collection of expressions.

outputs

a character vector giving the names of the variables that are assigned values in this block of code, including assignments to elements of a variable, e.g. the variable x in the expression x[[1]] <- 10.

character vector of variables which receive new values when evaluating the expression, but must already exist. Note this does not currently catch some situations, so checking if any symbols appear in both inputs and outputs is still prudent.

functions

a named logical vector, where the names are the names of the functions called and the values indicate whether the function is local (TRUE), from a package (FALSE) or unknown (NA). Note that this is not recursive.

removes

a vector of variables which were removed (via the rm function) in e

nsevalVars

A vector of variables which appear in appear in e, but which are non-standarly evaluated and thus are not typical inputs. Note this classification is determined by the functionhandlers in use by collector.

##### Note

Users should never call getInputs.langauge directly. It is listed here due to the vagaries of R CMD check documentation checks.

parse

##### Aliases
• getInputs
• getInputs,ANY-method
• getInputs,Script-method
• getInputs,ScriptNode-method
• getInputs,ScriptNodeInfo-method
• getInputs,function-method
• scriptInfo
##### Examples
# NOT RUN {
frags = parse(system.file("samples", "dual.R", package = "CodeDepends"))
# formula involves non-df variables
inputs = lapply(frags, getInputs, formulaInputs=TRUE)
inputs
sapply(inputs, slot, "outputs")

# Specify the base directory in which to resolve the file names.
getInputs(frags[[5]], basedir = system.file("samples", package = "CodeDepends"))

f = system.file("samples", "namedAnnotatedScript.R", package = "CodeDepends")