title: Growing a list with variable names in R
body: <p>I am trying to grow a list in R, where both the value and name of each entry is held in a variable, but it doesn't seem to work. </p>
  
  <pre><code>my_models_names &lt;- names(my_models)
  my_rocs=list() 
  for (modl in my_models_names) {
  
      my_probs &lt;- testPred[[modl]]$Y1
      my_roc &lt;- roc(Ytst, my_probs)
      c(my_rocs, modl=my_roc) # &lt;-- modl and my_roc are both variables
      }
  </code></pre>
  
  <p>My list <code>my_rocs</code> is empty at the end, even though I know that the loop iterates (<code>my_roc</code> is filled in) Why? </p>
  
  <p>On a related note, is there a way to do this without looping?</p>