title: Name list elements based on variable names R
body: <p>I want to add elements to an empty list on the fly. Each element in the list should  be named automatically after a set of variables which value will vary. </p>
  
  <p>However, I cannot seem to find a way to name list elements on the fly without getting errors. Consider the example below:</p>
  
  <pre><code>L &lt;- list()
  
  var1 &lt;- "wood"
  var2 &lt;- 1.0
  var3 &lt;- "z4"
  
  varname &lt;- paste(var1, as.character(var2), var3, sep="_")
  
  # This works fine:
  L$"wood_1_z4" &lt;- c(0,1)
  L$"wood_1_z4"
  0 1
  
  # This doesn't!!
  L$paste(var1, as.character(var2), var3, sep="_") &lt;- c(0,1)
  Error in L$paste(var1, as.character(var2), var3, sep = "_") &lt;- c(0, 1) : 
    invalid function in complex assignment
  
  # Ths doesn't either ... 
  L$eval(parse(text = "varname")) &lt;- c(0,1)
  Error in L$eval(parse(text = "varname")) &lt;- c(0, 1) : 
  target of assignment expands to non-language object
  </code></pre>
  
  <p>Is there a way to do this?</p>