In-place modification doesn't work in RStudio

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?

Probably!


But note the latest twist in the rather lengthy back and forth at the above link — it seems pretty hard to predict when you get a modify-in-place. I think the upshot for me was this bit of advice:

While determining that copies are being made is not hard, preventing such behaviour is. If you find yourself resorting to exotic tricks to avoid copies, it may be time to rewrite your function in C++, as described in Rcpp.

2 Likes