Partial Substitution in Expressions

DESCRIPTION:

Returns a quoted expression, where parts of the expression wrapped in ".()" are evaluated in the environment specified by the where argument.

USAGE:

bquote(expr, where=parent.frame())

REQUIRED ARGUMENTS:

expr
a S-PLUS expression that can include terms wrapped in ".()" which says to evaluate the enclosed term.

OPTIONAL ARGUMENTS:

where
either an integer specifying a frame or a list of named elements defining the names occurring in the expression. This argument is similar to the local argument in the function eval and the frame argument in the function substitute.

VALUE:

an expression similar to the input expression but with all terms wrapped in ".()" replaced by their values.

SIDE EFFECTS:

Expressions that are wrapped in ".()" will be evaluated and can have side effects.

DETAILS:

This function emulates R's bquote function, but is implemented using the S-PLUS function rapply. bquote is similar in function to the LISP backquote macro.

SEE ALSO:

, , .

EXAMPLES:

a <- 1
bquote(log(.(a)) == .(log(a)))
# result: log(1) == 0.
bquote(log(.(a)) == .(log(a)), list(a = exp(1)))
# result: log(2.71828182845905) == 1.
bquote(y ~ .(f)(x), list(f = as.name("log")))
# result: y ~ log(x)