Description Usage Arguments Details Value Warning Examples
A reimplementation of the backquote macro from Lisp/Scheme, with more
functionality than the base bquote
function. quasiquote quotes
its argument, except for two kinds of user-requested evaluation and
interpolation. Adapted from base R's bquote
.
1 | quasiquote(expr, where = parent.frame())
|
expr |
The expression to be partially quoted. |
where |
The environment in which any evaluation should occur. |
Unlike the bquote() found in base R, this version handles both of the types of unquoting Lisp provides:
terms wrapped in .c()
are evaluated in the environment given
by where
. This feature replicates Lisp's unquote
, or the
comma notation, and behaves identically to bquote
's .()
.
terms wrapped in .s()
are evaluated in the environment given
by where
, are assumed to evaluate to a list, pairlist or vector,
and its elements are spliced into the expression where the .s()
occurred. This feature replicates Lisp's unquote-splicing
, or the
comma-at notation.
The quoted expr, with partial evaluation and substitution done.
Splicing unquote via .s()
works on a purely lexical basis, and unlike
in Lisp, there is no guarantee the resulting object will make any sense.
1 2 3 4 5 | f <- list(1,2,3)
eval(quasiquote(list(.c(f), 4, 5, 6)))
f <- list(5,6,7)
eval(quasiquote(list(1, 2, 3, 4, .s(f), 8, 9, 10)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.