as_quosure

0th

Percentile

Coerce object to quosure

While new_quosure() wraps any R object (including expressions, formulas, or other quosures) into a quosure, as_quosure() converts formulas and quosures and does not double-wrap.

Usage
as_quosure(x, env = caller_env())

new_quosure(expr, env = caller_env())

Arguments
x

An object to convert. Either an expression or a formula.

env

The original context of the context expression.

expr

The expression wrapped by the quosure.

Life cycle

  • Like the rest of the rlang package, new_quosure() and as_quosure() are maturing.

  • 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.

See Also

quo(), is_quosure()

Aliases
  • as_quosure
  • new_quosure
Examples
library(rlang) # NOT RUN { # as_quosure() converts expressions or any R object to a validly # scoped quosure: as_quosure(quote(expr), base_env()) as_quosure(10L, base_env()) # Sometimes you get unscoped formulas because of quotation: f <- ~~expr inner_f <- f_rhs(f) str(inner_f) # In that case testing for a scoped formula returns FALSE: is_formula(inner_f, scoped = TRUE) # With as_quosure() you ensure that this kind of unscoped formulas # will be granted a default environment: as_quosure(inner_f, base_env()) # }
Documentation reproduced from package rlang, version 0.2.0, License: GPL-3

Community examples

Looks like there are no examples yet.