# NOT RUN {
# quos() is like the singular version but allows quoting
# several arguments:
quos(foo(), bar(baz), letters[1:2], !! letters[1:2])
# It is most useful when used with dots. This allows quoting
# expressions across different levels of function calls:
fn <- function(...) quos(...)
fn(foo(bar), baz)
# Note that quos() does not check for duplicate named
# arguments:
fn <- function(...) quos(x = x, ...)
fn(x = a + b)
# Dots can be spliced in:
args <- list(x = 1:3, y = ~var)
quos(!!! args, z = 10L)
# Raw expressions are turned to formulas:
args <- alist(x = foo, y = bar)
quos(!!! args)
# Definitions are treated similarly to named arguments:
quos(x := expr, y = expr)
# However, the LHS of definitions can be unquoted. The return value
# must be a symbol or a string:
var <- "foo"
quos(!!var := expr)
# If you need the full LHS expression, use dots_definitions():
dots <- dots_definitions(var = foo(baz) := bar(baz))
dots$defs
# }
Run the code above in your browser using DataLab