I have a data.frame called my.data with 2,000 columns and object.size(my.data)
returns around 450 MB.
I removed unnecessary columns by keeping only the ones (around 300 columns) I need
my.data <- my.data[,vars.keep]
gc()
Then I checked object.size(my.data) again and it's still 450 MB. How could I get back the memory in a efficient way?
Just want to add some more info, Maurits is right. After removing unnecessary columns, object size decreased dramatically, but rsession still uses same memory. Why doesn't rsession release the memory...?
format(object.size(transformed_data), units = "Mb");
[1] "40.5 Mb"
transformed_data <- transformed_data[,vars.keep]
format(object.size(transformed_data), units = "Mb");
[1] "5.3 Mb"