[R] Merging RData files

Henrik Bengtsson henrik.bengtsson at gmail.com
Tue Jan 16 19:57:15 CET 2018


To expand on what Bert suggests.  Use:

loadToEnv <- function(file, ..., envir = new.env()) {
  base::load(file = file, envir = envir, ...)
}

envA <- loadToEnv("a.RData")
envB <- loadToEnv("b.RData")

and then access the objects in environments envA and envB using
environment access methods, e.g. ls(envir = envA), envA[[name]],
envA$foo, as.list(envA) [careful is large objects], ...

/H

On Tue, Jan 16, 2018 at 7:30 AM, Bert Gunter <bgunter.4567 at gmail.com> wrote:
> ?load
>
> Read this carefully. Pay attention to its instructions re: overwriting
> existing objects.
>
> Cheers,
> Bert
>
>
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
> On Tue, Jan 16, 2018 at 12:43 AM, Steven Yen <styen at ntu.edu.tw> wrote:
>
>> I ran two separate hours-long projects. Results of each were saved to
>> two separate .RData files.
>> Content of each includes, among others, the following:
>>
>>                     me    se      t     p sig
>> pc21.age        0.640 0.219  2.918 0.004 ***
>> pc21.agesq      0.000 0.000    NaN   NaN
>> pc21.inc        0.903 0.103  8.752 0.000 ***
>> pc21.incsq      0.000 0.000    NaN   NaN
>> pc21.sei10      0.451 0.145  3.122 0.002 ***
>> pc21.sblkprot  -4.334 3.387  1.280 0.201
>> ...
>>
>> Question: How can I combine/consolidate the two .RData files into one?
>> Thank you.
>>
>>
>>
>>
>>
>>         [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/
>> posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list