Arguments

the environment in which expr is to
be evaluated. May also be, NULL, a list, a data frame,
or an integer as in sys.call.

enclos

Relevant when envir is a list or a data frame.
Specifies the
enclosure, i.e., where R looks for objects not found in
envir.

n

parent generations to go back

Details

eval evaluates the expression expr argument in the
environment specified by envir and returns the computed value.
If envir is not specified, then
sys.frame(sys.parent()), the environment where
the call to eval was made is used.

The evalq form is equivalent to eval(quote(expr), ...).

As eval evaluates its first argument before passing it to the
evaluator, it allows you to assign complicated expressions to symbols
and then evaluate them. evalq avoids this.

eval.parent(expr, n) is a shorthand for eval(expr,
parent.frame(n)).

If envir is a data frame or list, it is copied into a temporary
environment, and the copy is used for evaluation. So if expr
changes any of the components named in the data frame/list, the changes
are lost.

If envir is NULL it is treated as an empty list or data
frame: no values will be found in envir, so look-up goes
directly to enclos.

A value of NULL for enclos is interpreted as the
environment of the base package.

local evaluates an expression in a local environment. It is
equivalent to evalq except the its default argument creates a
new, empty environment. This is useful to create anonymous recursive
functions and as a kind of limited namespace feature since variables
defined in the environment are not visible from the outside.

Note

Due to the difference in scoping rules, there are some differences
between R and S in this area. In particular, the default enclosure
in S is the global environment.

When evaluating expressions in data frames that has been passed as
argument to a function, the relevant enclosure is often the caller's
environment, i.e., one needs
eval(x, data, parent.frame()).