title: Can I save the temporary environment of a function in R?
body: <p>I'm currently writing a rather large function for a specific plot. I would like to keep all the objects created by the function for bugfixing reasons, but my web search so far has been unsuccessful.</p>
  
  <p>A quick visualization. Suppose </p>
  
  <pre><code>fun &lt;- function(x) {
    y &lt;- x+1
    z &lt;- y^2
    z*4
  }
  
  fun(2)
  [1] 36
  </code></pre>
  
  <p>For this simple case, I would like to keep y and z in an accessible environment to be able to comprehend which results certain stages of my function produce.</p>
  
  <p>Thanks in advance!</p>