I'm exploring the use of tracemem, and starting with a brand new R session, I type
x <- 1:3
tracemem(x)
#[1] "<000002ACC3C51E80"
y <- 4:6
y <- x
y[1] <- 1
#tracemem[0x000002acc3c51e80 - 0x000002acbff1e038]:
#tracemem[0x000002acbff1e038 - 0x000002acc75a7358]:
y[2] <- 2
#tracemem[0x000002acc75a7358 - 0x000002acc75ab0f8]:
y[2] <- 3
#tracemem[0x000002acc75ab0f8 - 0x000002acc75b0bb8]:
z <- 9:10
z <- 1:2
y <- z
I can see why tracemem
prints a change in address when I type y[1] <- 1
(an entirely new copy of y is made), but why does it print a change in address when I then type y[2] <- 2
and y[2] <- 3
? Isn't y completely divorced from x at this point? It does not print anything when I later type y=z
, and this is what I expect, but I don't have a clear understanding of why it printed traces for y[2] <- 2
and y[2] <- 3
. What am I missing here?