I have a huge data frame loaded in global environment in R named df. How can I rename the data frame without copying the data frame by assigning it to another s
There is a function called mv in the gdata package.
library(gdata)
x <- data.frame(A = 1:100, B = 101:200, C = 201:300)
tracemem(x)
"<0000000024EA66F8>"
mv(from = "x", to = "y")
tracemem(y)
"<0000000024EA66F8>"
You will notice that the output from tracemem is identical for x and y. Looking at the code of mv, you will see that it assigns the object to the environment in scope and then removes the old object. This is quite similar to the approach C8H10N4O2 used (although mv is for a single object), but at least the function is convenient to use.