These functions return raw expressions (whereas quo() and variants return quosures). They support quasiquotation syntax.

  • expr() returns its argument unevaluated. It is equivalent to base::bquote().

  • enexpr() takes an argument name and returns it unevaluated. It is equivalent to base::substitute().

  • exprs() captures multiple expressions and returns a list. In particular, it can capture expressions in .... It supports name unquoting with := (see quos()). It is equivalent to eval(substitute(alist(...))).

See is_expr() for more about R expressions.



exprs(..., .ignore_empty = "trailing")



An expression.


A symbol referring to an argument. The expression supplied to that argument will be captured unevaluated.


Arguments to extract.


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


The raw expression supplied as argument. exprs() returns a list of expressions.

See also

quo(), is_expr()


# The advantage of expr() over quote() is that it unquotes on # capture: expr(list(1, !! 3 + 10))
#> list(1, 13)
# Unquoting can be especially useful for successive transformation # of a captured expression: (expr <- quote(foo(bar)))
#> foo(bar)
(expr <- expr(inner(!! expr, arg1)))
#> inner(foo(bar), arg1)
(expr <- expr(outer(!! expr, !!! lapply(letters[1:3], as.symbol))))
#> outer(inner(foo(bar), arg1), a, b, c)
# Unlike quo(), expr() produces expressions that can # be evaluated with base::eval(): e <- quote(letters) e <- expr(toupper(!!e)) eval(e)
#> [1] "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" #> [20] "T" "U" "V" "W" "X" "Y" "Z"
# Be careful if you unquote a quosure: you need to take the RHS # (and lose the scope information) to evaluate with eval(): f <- quo(letters) e <- expr(toupper(!! get_expr(f))) eval(e)
#> [1] "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" #> [20] "T" "U" "V" "W" "X" "Y" "Z"
# On the other hand it's fine to unquote quosures if you evaluate # with eval_tidy(): f <- quo(letters) e <- expr(toupper(!! f)) eval_tidy(e)
#> [1] "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" #> [20] "T" "U" "V" "W" "X" "Y" "Z"
# exprs() lets you unquote names with the definition operator: nm <- "foo" exprs(a = 1, !! nm := 2)
#> $a #> [1] 1 #> #> $foo #> [1] 2 #>