Skip to content
Prev 138362 / 398506 Next

renaming objects

or, in other terms:

 > set.seed(1)
 > x <- runif(1e7)
 > x.add <- tracemem(x)
 > y <- x
 > y.add <- tracemem(y)
 > identical(x.add, y.add)
[1] TRUE

ie, both objects have the same memory address - therefore, not a copy:

 > x.add
[1] "<0x2000000>"
 > y.add
[1] "<0x2000000>"

now, observe what happens when you modify "y"

 > y[1] <- 1
tracemem[0x2000000 -> 0x6c4c000]:
 > tracemem(y)
[1] "<0x6c4c000>"

now, it's a copy... =)

b
On Mar 3, 2008, at 5:48 PM, hadley wickham wrote: