title: How to store matrices inside a loop in R
body: <p>I've got a simple question that I can't figure out: I would like to store matrices produced in a loop into one full storage matrix. For example, the following code generates a matrix 5x5 each iteration for three iterations but is unable to store them into one 5x15 matrix:</p>
  
  <pre><code>species_samp &lt;- sample(unique(iris$Species))
  store &lt;- matrix(NA, ncol =5, nrow = 15)
  
  for(i in 1:3){
  
      samp    &lt;- iris[sample(nrow(iris[iris$Species==species_samp[i],]), 5),]
      store[i,] &lt;- samp
  }   
  </code></pre>
  
  <p>This fails, however I would like to ultimately have a store matrix with the the full matrix that gets sampled in each iteration of the loop. Any and all help appreciated. Thanks. </p>