bquote_function | R Documentation |
bquote_function is for adapting a function defined elsewhere for bquote-enabled argument substitution.
Re-write call to evaluate expr
with bquote
.()
substitution.
Uses convetion that := is considered a alias for =.
Including .(-x)
promoting x
's value from character to a name,
which is called "quote negation" (hence the minus-sign).
bquote_function(fn)
fn |
function to adapt, must have non-empty formals(). |
new function.
bquote_call_args
if(requireNamespace('graphics', quietly = TRUE)) {
angle = 1:10
variable <- as.name("angle")
plotb <- bquote_function(graphics::plot)
plotb(x = .(variable), y = sin(.(variable)))
}
f1 <- function(x) { substitute(x) }
f2 <- bquote_function(f1)
arg <- "USER_ARG"
f2(arg) # returns arg
f2(.(arg)) # returns "USER_ARG" (character)
f2(.(-arg)) # returns USER_ARG (name)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.