eval_unquoted: Execute code after tidy evaluation

Description Usage Arguments Value Examples

View source: R/rlang-like.R

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

1

Arguments

...

R code snippets

Value

The value of the last evaluated expression.

Examples

1
2
3
4
5
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 8, 2021, 5:07 p.m.