title: Change list items in for loop in R
body: <p>I used to work in C++ and I think I am misunderstanding how for-loops (or iterations) work in R. I want to change list items in a for loop, but the for loop seems to make a temporary copy and only change that? How can I prevent this? This seems like a trivial beginners question, but I was unable to find a tutorial / question on stackoverflow about why this happens.</p>
  
  <p>Code:</p>
  
  <pre><code>myList &lt;- list(a=1, b=1, c=1, d=1)
  for(item in myList){item &lt;- 3}
  myList
  # Expected output: 3,3,3,3 - Real output: 1,1,1,1
  # Additionally, I now have a variable "item" with value 3.
  </code></pre>