Take this code:
x <- runif(1e8) pryr::refs(x) system.time(x[] <- 1) system.time(x[] <- 1)
- If I run it in RStudio, all at once, modification is done in-place, OK.
- If I run it in RStudio, one line at a time, it creates a copy when changing the first element of the vector.
- If I run it in a terminal, it works fine.
Is it because of the object explorer of RStudio creating a reference to the same object so that it has to copy it if I modify one element?
- R 3.4.0
- RStudio 1.1.442
- Windows >= 10