Vocabulary of Tidy Evaluation

Anthony Chau

2020/06/22

After struggling how to program with dplyr, I decided it would be best to write a blog post about it. These notes are referenced from this cheatsheet

Fundamental terminology:

In the example below, we capture the expression a + b. It doesn’t matter if we defined symbols a and b before.

c <- rlang::expr(a + b)
c
> a + b
# no attributes
attributes(1)
> NULL
attributes("1")
> NULL
attributes(TRUE)
> NULL
attributes(list(1, 2, 3))
> NULL
# data frame is not bare 
# it has attributes
attributes(data.frame(x = c(1,3)))
> $names
> [1] "x"
> 
> $class
> [1] "data.frame"
> 
> $row.names
> [1] 1 2

Below, we have introduced two new bindings to the global environment. We bind the symbol a to the constant 1 and the symbol b to the constant “hello”. And, objects a and b are now objects in memory within the global environment

a <- 1
b <- "hello"
sum(1 + 2)
> [1] 3