% Generated by roxygen2: do not edit by hand % Please edit documentation in R/eval-tidy.R \name{eval_tidy} \alias{eval_tidy} \title{Evaluate an expression with quosures and pronoun support} \usage{ eval_tidy(expr, data = NULL, env = caller_env()) } \arguments{ \item{expr}{An \link[=topic-defuse]{expression} or \link[=topic-quosure]{quosure} to evaluate.} \item{data}{A data frame, or named list or vector. Alternatively, a data mask created with \code{\link[=as_data_mask]{as_data_mask()}} or \code{\link[=new_data_mask]{new_data_mask()}}. Objects in \code{data} have priority over those in \code{env}. See the section about data masking.} \item{env}{The environment in which to evaluate \code{expr}. This environment is not applicable for quosures because they have their own environments.} } \description{ \code{eval_tidy()} is a variant of \code{\link[base:eval]{base::eval()}} that powers the tidy evaluation framework. Like \code{eval()} it accepts user data as argument. Whereas \code{eval()} simply transforms the data to an environment, \code{eval_tidy()} transforms it to a \link[=topic-data-mask]{data mask} with \code{\link[=as_data_mask]{as_data_mask()}}. Evaluating in a data mask enables the following features: \itemize{ \item \link[=topic-quosure]{Quosures}. Quosures are expressions bundled with an environment. If \code{data} is supplied, objects in the data mask always have precedence over the quosure environment, i.e. the data masks the environment. \item \link[=.data]{Pronouns}. If \code{data} is supplied, the \code{.env} and \code{.data} pronouns are installed in the data mask. \code{.env} is a reference to the calling environment and \code{.data} refers to the \code{data} argument. These pronouns are an escape hatch for the \link[=topic-data-mask-ambiguity]{data mask ambiguity} problem. } } \section{When should eval_tidy() be used instead of eval()?}{ \code{base::eval()} is sufficient for simple evaluation. Use \code{eval_tidy()} when you'd like to support expressions referring to the \code{.data} pronoun, or when you need to support quosures. If you're evaluating an expression captured with \link[=topic-inject]{injection} support, it is recommended to use \code{eval_tidy()} because users may inject quosures. Note that unwrapping a quosure with \code{\link[=quo_get_expr]{quo_get_expr()}} does not guarantee that there is no quosures inside the expression. Quosures might be unquoted anywhere in the expression tree. For instance, the following does not work reliably in the presence of nested quosures: \if{html}{\out{