title: lapply and rbind not properly appending the results
body: <pre><code> SimNo &lt;- 10
  
   for (i in 1:SimNo){
    z1&lt;-rnorm(1000,0,1)
    z2&lt;-rnorm(1000,0,1)
    z3&lt;-rnorm(1000,0,1)
    z4&lt;-rnorm(1000,0,1)
    z5&lt;-rnorm(1000,0,1)
    z6&lt;-rnorm(1000,0,1)
  
    X&lt;-cbind(z1,z2,z3,z4,z5,z6)
    sx&lt;-scale(X)/sqrt(999)
    det1&lt;-det(t(sx)%*%sx)
    detans&lt;-do.call(rbind,lapply(1:SimNo, function(x) ifelse(det1&lt;1,det1,0)))
   }
  </code></pre>
  
  <p>when I run all commands with in loop except last one I get different values of determinant but when I run code with loops at once I get last value of determinant repeated for all.</p>
  
  <p>Please help and guide to control all situation like this.</p>
  
  <p>Is there way to have short and efficient way for this code, so that each individual variable can also be accessed.</p>