bquote
Partial Substitution in Expressions
Description
Returns a quoted expression, where the parts of the expression
wrapped in .() are evaluated in the environment
specified by the where argument.
Usage
bquote(expr, where = parent.frame(), splice = FALSE)
Arguments
expr |
an expression. Can include terms wrapped in .() indicating that
the enclosed term should be evaluated.
If this argument is missing, the missing value symbol itself is returned.
|
where |
an integer specifying a frame, an environment, or a list of named elements
defining the names occurring in the expression.
This argument is similar to the envir argument in the function
eval.
|
splice |
a logical value.
- If TRUE, then calls of the form ..(a1)
in a call in expr can change the number of arguments in the call.
All the values in the evaluation of a1 are interpolated into the call
containing the call to ..(a1).
- If FALSE (the default), then only calls of the form .(a1) are processed.
Calls to ..() should occur only in calls.
|
Details
bquote is similar in function to the LISP macro backquote.
Value
returns an expression similar to the input expression, but with all terms
wrapped in .() replaced by their values.
Side Effects
Expressions that are wrapped in .()
(or ..(), if splice is TRUE)
are evaluated and can have side effects.
See Also
Examples
a <- 1
bquote(log(.(a)) == .(log(a)))
bquote(log(.(a)) == .(log(a)), list(a = exp(1)))
bquote(y ~ .(f)(x), list(f = as.name("log")))
bquote(func(.(x), ..(extras)), list(x=quote(log(ex)), extras=expression(1+2, 3/4)), splice=TRUE)
bquote(func(.(x), .(extras)), list(x=quote(log(ex)), extras=expression(1+2, 3/4)), splice=FALSE)