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))))
)
)
Run the code above in your browser using DataLab