title: efficiently move environment from inside function to global environment
body: <p>I have a function that creates an environment within it and i wish to assign that environment to the global environment. At present i do this by assigning the environment to <code>globalenv()</code> as the final step -- as follows:</p>
  
  <pre><code>funfun &lt;- function(inc = 1){
      dataEnv &lt;- new.env()
      dataEnv$d1 &lt;- 1 + inc
      dataEnv$d2 &lt;- 2 + inc
      dataEnv$d3 &lt;- 2 + inc
      assign('dataEnv', dataEnv, envir = globalenv())
  }
  </code></pre>
  
  <p>It feels like i should be able to do something to make <code>dataEnv</code> persisit when the function <code>funfun</code> ends (to save copying the environment at the end) however my attempts, such as <code>dataEnv &lt;- new.env(parent = globalenv())</code>, have not worked. </p>
  
  <p>Why does it fail? Is this possible? </p>
  
  <p>Also, what is the most efficient way of doing this? </p>
  
  <p>My tables are very large at times, and the copying will become an issue as the project grows.  </p>