title: memory efficient way of passing large objects in R
body: <p>I have a function that needs to access a variable in its parent environment (scope from which the function is called).  The variable is large in terms of memory so I would prefer not to pass it to by value to the function being called.  Is there a standard way of doing this other than declaring the variable in the global scope?  For example:</p>
  
  <pre><code>g &lt;- function (a, b) { #do stuff}
  
  f &lt;- function(x) {
      y &lt;- 3 #but in my program y is very large
      g(x, y)
  }
  </code></pre>
  
  <p>I would like to access y in <code>g()</code>.  So something like this:</p>
  
  <pre><code>g &lt;- function (a) { a+y }
  
  f &lt;- function(x) {
      y &lt;- 3 #but in my program y is very large
      g(x)
  }
  </code></pre>
  
  <p>Is this possible?</p>
  
  <p>Thanks</p>