Binding basics

  • Create values and bind a name to them
  • Names have values (rather than values have names)
  • Multiple names can refer to the same values
  • We can look at an object’s address to keep track of the values independent of their names
x <- c(1, 2, 3)
y <- x
obj_addr(x)
#> [1] "0x560e536575b8"
obj_addr(y)
#> [1] "0x560e536575b8"

Exercises

1. Explain the relationships
a <- 1:10
b <- a
c <- b
d <- 1:10

a b and c are all names that refer to the first value 1:10

d is a name that refers to the second value of 1:10.

2. Do the following all point to the same underlying function object? hint: lobstr::obj_addr()
obj_addr(mean)
#> [1] "0x560e4e1898a8"
obj_addr(base::mean)
#> [1] "0x560e4e1898a8"
obj_addr(get("mean"))
#> [1] "0x560e4e1898a8"
obj_addr(evalq(mean))
#> [1] "0x560e4e1898a8"
obj_addr(match.fun("mean"))
#> [1] "0x560e4e1898a8"

Yes!