new_quosure() wraps any R object (including expressions,
formulas, or other quosures) into a quosure,
converts formulas and quosures and does not double-wrap.
as_quosure(x, env = NULL) new_quosure(expr, env = caller_env())
An object to convert. Either an expression or a formula.
The environment in which the expression should be evaluated. Only used for symbols and calls. This should typically be the environment in which the expression was created.
The expression wrapped by the quosure.
as_quosure() now requires an explicit default environment for
creating quosures from symbols and calls.
as_quosureish() is deprecated as of rlang 0.2.0. This function
assumes that quosures are formulas which is currently true but
might not be in the future.
# as_quosure() converts expressions or any R object to a validly # scoped quosure: env <- env(var = "thing") as_quosure(quote(var), env)#> <quosure> #> expr: ^var #> env: 0x4fc0080# The environment is ignored for formulas: as_quosure(~foo, env)#> <quosure> #> expr: ^foo #> env: 0x50e4110as_quosure(~foo)#> <quosure> #> expr: ^foo #> env: 0x50e4110#> Warning: `as_quosure()` requires an explicit environment as of rlang 0.3.0. #> Please supply `env`. #> This warning is displayed once per session.#> <quosure> #> expr: ^var #> env: 0x50e4110