Functions

  • Copying also applies within functions
  • If you copy (but don’t modify) x within f(), no copy is made
f <- function(a) {
  a
}

x <- c(1, 2, 3)
z <- f(x) # No change in value

ref(x)
#> [1:0x560e51c13b38] <dbl>
ref(z)
#> [1:0x560e51c13b38] <dbl>