title: Assignment in R language
body: <p>I am wondering how assignment works in the R language.</p>
  
  <p>Consider the following R shell session:</p>
  
  <pre><code>&gt; x &lt;- c(5, 6, 7)
  &gt; x[1] &lt;- 10
  &gt; x
  [1] 10 6 7
  &gt;
  </code></pre>
  
  <p>which I totally understand. The vector (5, 6, 7) is created and bound to
  the symbol 'x'. Later, 'x' is rebound to the new vector (10, 6, 7) because vectors
  are immutable data structures.</p>
  
  <p>But what happens here:</p>
  
  <pre><code>&gt; c(4, 5, 6)[1] &lt;- 10
  Error in c(4, 5, 6)[1] &lt;- 10 :
    target of assignment expands to non-language object
  &gt;
  </code></pre>
  
  <p>or here:</p>
  
  <pre><code>&gt; f &lt;- function() c(4, 5, 6)
  &gt; f()[1] &lt;- 10
  Error in f()[1] &lt;- 10 : invalid (NULL) left side of assignment
  &gt;
  </code></pre>
  
  <p>It seems to me that one can only assign values to named data structures  (like 'x').</p>
  
  <p>The reason why I am asking is because I try to implement the R language core and I am unsure
  how to deal with such assignments.</p>
  
  <p>Thanks in advance</p>