title: Sequentially naming variables (beginner)
body: <p>I would like to assign data created within a loop to a corresponding series of sequentially- numbered variables.   As written, the loop in this example simply overwrites each time, so that all is stored is the final dataset assigned to matrix stooges.  What I would like to do is to have each iteration create a new variable, called “somename(counter)”, and store the current values for matrix stooges in that variable.  The loop below, then, should create variables somename0, with values 0,0,0,0, somename1, with values 1:4, and somename2 with values 2,4,6,8. I think creating the variables dynamically within the loop is best in order to automate the naming of the variables and how many are created.</p>
  
  <p>ex:</p>
  
  <pre><code>no_its &lt;- 3  
  counter &lt;- 0
  while(counter &lt; no_its){
      a &lt;- c(counter*(1:4))
      stooges &lt;- as.matrix(a)
      rownames(stooges)&lt;-c("Larry","Moe","Curly","Shemp")
      counter &lt;- counter+1
  }
  stooges
  
  output:
        [,1]
  Larry    2
  Moe      4
  Curly    6
  Shemp    8
  </code></pre>