Description Usage Arguments Details Value Note Author(s) Examples
Technically, this defines two nested environments, the outer containing functions and the inner containing names, and returns the inner.
1 | quoting.env(names, parent = emptyenv(), call.names = names)
|
names |
The names the environment should define. |
parent |
The parent environment (defaults to the empty environment) |
call.names |
The functions the enclosing environment should
define. Decaults to |
This somewhat esoteric function mostly intended to be used by
expand_macros
The environment constructed.
This will cause errors when the expression has missing arguments. The expression might be preprocessed (somewhow?) to take missing arguments out.
Peter Meilstrup
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | en <- quoting.env(c('+', '(', 'a', 'b', '*'), environment())
evalq(a+b, en) # a+b
evalq(a+(b*a), en) # a+(b*a)
z <- 100
evalq(a+(b*a)*z, en) #a+(b*a)*100
##We can build a function that does something like substitute() like this:
ersatz.substitute <- function(expr, envir=arg_env(expr)) {
parent <- as.environment(envir)
en <- quoting.env(setdiff(all.names(expr), ls(parent)), parent)
eval(expr, en)
}
ersatz.substitute(quote(a+b+c), list(b=quote(q+y))) # returns a+(q+y)+c
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.