call_concatenate | R Documentation |
e.g. combine with +
for ggplot
without introducing parentheses due to associativity
call_concatenate(args, bin_op = "+")
args |
arguments to concatenate with operator |
bin_op |
binary operator to concatenate it with |
a call
library(ggplot2)
# What we want to achieve
call("+", quote(f), quote(g))
call("+", quote(f), call("+", quote(g), quote(h))) # parentheses not wanted
call("+", call("+", quote(f), quote(g)), quote(h)) # as expected without unnecessary parentheses
Reduce(function(existing, new) call("+", existing, new), list(quote(f), quote(g), quote(h)))
# how we do it
call_concatenate(list(quote(f), quote(g), quote(h)))
call_concatenate(list(quote(f)))
call_concatenate(list())
call_concatenate(
list(quote(ggplot(mtcars)), quote(geom_point(aes(wt, mpg))))
)
eval(
call_concatenate(
list(quote(ggplot(mtcars)), quote(geom_point(aes(wt, mpg))))
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.