user3056633 user3056633 - 8 months ago 72
R Question

How to merge three .RData files with same object name in R

I am a new user of R. I have three RData files with the same object name and I want to merge it so that I will have one .Rdata file with one object name.


  • file1.RData with object name A

  • file2.RData with object name A

  • file3.RData with object name A

and Result should be

  • file.RData = object A

I tried rbind and merge command, but nothing is working.


You will need to save them as new objects as you load each, then do your merging. For example, here, create a list to hold the objects. Then, as you load each, add that version to your list.

listForFiles <- list()

listForFiles[[1]] <- A

listForFiles[[2]] <- A

listForFiles[[3]] <- A

Then, you can use listForFiles to do your merging. Since you don't say what kind of object these are, I can't suggest an approach.