title: R: loading multiple RData with mclapply doesn't work
body: <p>I wanted to load multiple RData in one command, as explained by <a href="https://stackoverflow.com/a/3764352/10580090">Johua</a> using</p>
  <pre><code>&gt; lapply(c(a_data, b_data, c_data, d_data), load, .GlobalEnv)
  [[1]]
  [1] &quot;nRTC_Data&quot;
  
  [[2]]
  [1] &quot;RTA_Data&quot;
  
  [[3]]
  [1] &quot;RTC_Data&quot;
  
  [[4]]
  [1] &quot;RTA_Data&quot;
  
  &gt; rm(a_data, b_data, c_data, d_data); ls()
   [1] &quot;nRTC_Data&quot;       &quot;RTA_Data&quot;           &quot;RTAC_data&quot;     &quot;RTC_Data&quot;    
        
  </code></pre>
  <p>However, since my RData are big, and I found no time improvement between <code>lappy()</code> and multiple <code>load()</code>, I decided to use multi-core approach like following:</p>
  <pre><code>library(parallel)
  mclapply(c(a_data, b_data, c_data, d_data),load,.GlobalEnv, mc.cores = parallel::detectCores())
  </code></pre>
  <p>Though this significantly improved the loading time, also returns the list</p>
  <pre><code>   [[1]]
      [1] &quot;nRTC_Data&quot;
      
      [[2]]
      [1] &quot;RTA_Data&quot;
      
      [[3]]
      [1] &quot;RTC_Data&quot;
      
      [[4]]
      [1] &quot;RTA_Data&quot;
  </code></pre>
  <p>In my workspace, nothing is found</p>
  <pre><code>&gt; rm(a_data, b_data, c_data, d_data); ls()
  character(0)
  </code></pre>
  <p>I also tried replacing <code>.GlobalEnv</code> by <code>environment()</code>, but still didn't work.</p>
  <p>Any one has a clue?</p>
  <p>FYI, you can try with following commands:</p>
  <pre><code>&gt; a = &quot;aa&quot;;save(a, file = &quot;aa.RData&quot;)
  &gt; b = &quot;bb&quot;;save(b, file = &quot;bb.RData&quot;)
  &gt; c = &quot;cc&quot;;save(c, file = &quot;cc.RData&quot;)
  &gt; d = &quot;dd&quot;;save(d, file = &quot;dd.RData&quot;)
  
  &gt; # lapply approach
  &gt; rm(list = ls())
  &gt; a = &quot;aa.RData&quot;; b = &quot;bb.RData&quot;; c = &quot;cc.RData&quot;; d = &quot;dd.RData&quot;
  &gt; lapply(c(a, b, c, d), load, .GlobalEnv); rm(a, b, c, d) 
  
  &gt; # mclapply approach
  &gt; rm(list = ls())
  &gt; a = &quot;aa.RData&quot;; b = &quot;bb.RData&quot;; c = &quot;cc.RData&quot;; d = &quot;dd.RData&quot;
  &gt; mclapply(c(a, b, c, d), load, .GlobalEnv, mc.cores = parallel::detectCores()); rm(a, b, c, d)
  </code></pre>