Aliases: eval_tidy
Keywords:
### ** Examples # With simple defused expressions eval_tidy() works the same way as # eval(): fruit <- "apple" vegetable <- "potato" expr <- quote(paste(fruit, vegetable, sep = " or ")) expr
paste(fruit, vegetable, sep = " or ")
eval(expr)
[1] "apple or potato"
eval_tidy(expr)
[1] "apple or potato"
# Both accept a data mask as argument: data <- list(fruit = "banana", vegetable = "carrot") eval(expr, data)
[1] "banana or carrot"
eval_tidy(expr, data)
[1] "banana or carrot"
# The main difference is that eval_tidy() supports quosures: with_data <- function(data, expr) { quo <- enquo(expr) eval_tidy(quo, data) } with_data(NULL, fruit)
[1] "apple"
with_data(data, fruit)
[1] "banana"
# eval_tidy() installs the `.data` and `.env` pronouns to allow # users to be explicit about variable references: with_data(data, .data$fruit)
[1] "banana"
with_data(data, .env$fruit)
[1] "apple"