title: Change values of a dynamically selected list in R
body: <p>I have a number of lists in base R, I want to loop over these lists and make a change to the list elements. I want to do this change in one line, hard coding the name of every list is not an option:</p>
  
  <pre><code>a &lt;- list(thing1=1:5,
            thing2=6:10)
  
  b &lt;- list(thing1=1:5,
            thing2=6:10)
  
  for(list in c("a","b"){
  
     an_element &lt;- paste(list,
                         "$thing1",
                        sep="") # i.e "a$thing1"
  
      assign(an_element,20:25) # change value of element thing1 in lists
  
  }
  
  get("a$thing1") # shows change
  
  a$thing1 # does not show change
  </code></pre>
  
  <p>As the documentation for <code>assign</code> shows, object <code>a</code> has not been changed. I cannot pass <code>a</code> into subsequent functions and expect the values of <code>thing1</code> to be as I've changed them. I need a way to make the target of a reassignment operation dynamic, given by a variable.</p>