EvalExpressions: Evaluate a collection of Expressions

Description Usage Arguments Details Value See Also Examples

View source: R/EvalExpressions.R

Description

EvalExpressions evaluates one or more expressions, either in string format or as expression objects.

Usage

1
EvalExpressions(expressions, envir = parent.frame())

Arguments

expressions

an expression, or a collection of expressions.

envir

the environment in which expressions are to be evaluated. May also be NULL, a list, a data frame, a pair-list or an integer as specified in sys.call.

Details

EvalExpressions is a wrapper around eval and parse functions in R base package. It can handle a single, a vector or a list of expressions, character strings or GEPhenotype objects.

The envir argument is directly passed to eval function. If it is not specified, the parent frame (i.e., the environment where the call to eval was made) is used instead.

EvalExpressions only evaluates terminal expressions and character strings. Evaluating non-terminal expressions will result in a warning and NA is returned.

Value

If one expression is evaluated, a vector of numeric values is returned. Otherwise a data frame with result of each expression in a separate column is returned.

See Also

GrammarMap

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
A <- 1:6
B <- 1

EvalExpressions("A - B")

# a vector of text strings
exprs <- c("A + B", "A - B")
EvalExpressions(exprs, data.frame(A = A, B = B))

# a vector of expressions
exprs <- expression(A + B, A - B)
EvalExpressions(exprs, data.frame(A = A, B = B))

gramEvol documentation built on July 18, 2020, 5:07 p.m.