eval_unquoted: Execute code after tidy evaluation

View source: R/rlang-like.R

eval_unquotedR Documentation

Execute code after tidy evaluation

Description

This function takes R code as arguments and executes this code in the calling environment. All quoted variables (using rlang's quasiquotation, !! or !!!) will be unquoted prior to evaluation. This results in executed in code in which the variable is replaced verbatim by its value, as if you had typed the variable's value. This is particularly useful for functions using base R's substitute() approach, such as functions taking formulas, and you have built the formula dynamically. It is unnecessary for all functions based on tidy_eval (dplyr).

Usage

eval_unquoted(...)

Arguments

...

R code snippets

Value

The value of the last evaluated expression.

Examples

library(rlang)
# Note that evaluation takes place in the calling environment!
l <- quo(l <- 1) # l is a quosure in our env
eval_unquoted(!!l)
l == 1 # TRUE: l is now a vector

tidytidbits documentation built on March 18, 2022, 6:10 p.m.