title: R, deep vs. shallow copies, pass by reference
body: <p>I would like to understand the logic R uses when passing arguments to functions, creating copies of variables, etc. with respect to the memory usage.  When does it actually create a copy of the variable vs. just passing a reference to that variable?  In particular the situations I am curious about are:</p>
  
  <pre><code>f &lt;- function(x) {x+1}
  a &lt;- 1
  f(a)
  </code></pre>
  
  <p>Is <code>a</code> being passed literally or is a reference to a being passed?</p>
  
  <pre><code>x &lt;- 1
  y &lt;- x
  </code></pre>
  
  <p>Reference of copy?  When is this not the case?</p>
  
  <p>If someone could explain this to me I would highly appreciate.</p>