Learn R Programming

gramEvol (version 2.1-4)

EvalExpressions: Evaluate a collection of Expressions

Description

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

Usage

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.

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.

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.

See Also

GrammarMap

Examples

Run this code
# NOT RUN {
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))
# }

Run the code above in your browser using DataLab