Tidy quotation of multiple expressions and dots

quos() quotes its arguments and returns them as a list of quosures (see quo()). It is especially useful to capture arguments forwarded through ....

dots_definitions(..., .named = FALSE)

quos(..., .named = FALSE, .ignore_empty = c("trailing", "none", "all"))



Expressions to capture unevaluated.


Whether to ensure all dots are named. Unnamed elements are processed with expr_text() to figure out a default name. If an integer, it is passed to the width argument of expr_text(), if TRUE, the default width is used. See exprs_auto_name().


Whether to ignore empty arguments. Can be one of "trailing", "none", "all". If "trailing", only the last argument is ignored if it is empty.


An object to test.


Both quos and dots_definitions() have specific support for definition expressions of the type var := expr, with some differences:


When := definitions are supplied to quos(), they are treated as a synonym of argument assignment =. On the other hand, they allow unquoting operators on the left-hand side, which makes it easy to assign names programmatically.


This dots capturing function returns definitions as is. Unquote operators are processed on capture, in both the LHS and the RHS. Unlike quos(), it allows named definitions.

  • dots_definitions
  • quosures
  • quos
  • is_quosures
# 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))
# }
Documentation reproduced from package rlang, version 0.1.2, License: GPL-3

Community examples

Looks like there are no examples yet.