This set of functions are like
tidy_capture() but for
... arguments. They capture expressions passed through dots
along their dynamic environments, and return them bundled as a set
of formulas. They differ in their treatment of definition
expressions of the type
var := expr.
tidy_dots(..., .named = FALSE)tidy_defs(..., .named = FALSE)
- Arguments to capture.
- 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
TRUE, the default width is used.
# While tidy_capture() only work for the most direct calls, that's # not the case for tidy_dots(). Dots are forwarded all the way to # tidy_dots() and can be captured across multiple layers of calls: fn <- function(...) tidy_dots(y = a + b, ...) fn(z = a + b) # However if you pass a named argument in dots, only the expression # at the innermost call site is captured: fn <- function(...) tidy_dots(x = x) fn(x = a + b) # Dots can be spliced in: args <- list(x = 1:3, y = ~var) tidy_dots(!!! args, z = 10L) # Raw expressions are turned to formulas: args <- alist(x = foo, y = bar) tidy_dots(!!! args) # Definitions are treated similarly to named arguments: tidy_dots(x := expr, y = expr) # However, the LHS of definitions can be unquoted. The return value # must be a symbol or a string: var <- "foo" tidy_dots(!!var := expr) # If you need the full LHS expression, use tidy_defs(): dots <- tidy_defs(var = foo(baz) := bar(baz)) dots$defs