Tidyeval examples

Examples

Bang Bang – How to program with dplyr

About lazy evaluation

Tidy evaluation

Yet Another Introduction to tidyeval - Speaker Deck

Standard Non-Standard Evaluation: Tidy Eval | Tim Mastny

Scoping Rules and NSE

Standard Non-Standard Evaluation: Tidy Eval

Tidy Evaluation

tidy-eval-context

STANDARD AND NON-STANDARD EVALUATION IN R

Passing variable to function

library(tidyverse)
library(rlang)

x <- 1:32
mutate(starwars, height + x)
ggplot(starwars, aes(height, x))
lm(data = starwars, height ~ x)

x <- quote(letters[1:5])
eval(x)

a = mutate(starwars, bmi = mass / height^2)

x <- "height"
b = mutate(starwars, bmi = x)


var <- mtcars$cyl * 2
mutate(mtcars, cyl2 = cyl /(!! var)^2)

x <- sym("height")
expr((!! x)^2) 
expr(mutate(starwars, bmi = mass / (!! x)^2)) 
b = mutate(starwars, bmi = mass/ (!!x)^2)

test <- function(x){
  x <- sym(x)
  expr(mutate(starwars, bmi = mass / (!! x)^2)) 
}

test("height")

test1 <- function(x){
  x <- quo(x)
  expr(mutate(starwars, bmi = mass / (x)^2)) 
}

test1(height)