title: Rename a component of R lists
body: <pre><code>l1 &lt;- list(a = 'FirstComponent', b= 'SecondComponent')
  </code></pre>
  
  <p>To rename the first component from <code>a</code> to <code>c</code> I can do this:</p>
  
  <pre><code>names(l1) &lt;- c('c', 'b')
  </code></pre>
  
  <p>Or this:</p>
  
  <pre><code>names(l1)[1] &lt;- c('c')
  </code></pre>
  
  <p>But not this:</p>
  
  <pre><code>names(l1[1]) &lt;- c('c')
  </code></pre>
  
  <p>Nor this:</p>
  
  <pre><code>names(l1[[1]]) &lt;- c('c')
  </code></pre>
  
  <p>Why wouldn't the third and fourth code example work? They also try to rename an R object <code>l1[1]</code> and <code>l1[[1]]</code>. What's happening behind the scene?</p>
  
  <p>=========Following is part of the original question===========</p>
  
  <blockquote>
    <p>R documentation: it is possible to update just part of the names attribute via the general rules: see the examples. This works because the expression there is evaluated as <code>z &lt;- "names&lt;-"(z, "[&lt;-"(names(z), 3, "c2"))</code>.</p>
  </blockquote>
  
  <p>The returned value of <code>names(z)</code> in <code>"[&lt;-"(names(z), 3, "c2")</code> is passed to the next function as a parameter, which is <code>"[&lt;-"</code>.</p>