title: How to iteratively fill a matrix with rnorm values using a for loop?
body: <p>I have a question, I am trying to create a 10x10 matrix using the code below, where the first column contains 10 values from a normal distribution with std dev of .5 and a mean equal to j where j is a value 1:10. My code below produces the observed matrix, where only the final column is filled with values. What am I doing wrong? Thank you.</p>
  
  <pre><code>      for(j in 1:10){
        y&lt;-matrix(0,ncol=10,nrow=10)
          y[,j]&lt;-rnorm(n=10,mean=j,sd=.5)
  }
  
  
        [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]     [,10]
   [1,]    0    0    0    0    0    0    0    0    0 10.857520
   [2,]    0    0    0    0    0    0    0    0    0 10.490549
   [3,]    0    0    0    0    0    0    0    0    0  9.888620
   [4,]    0    0    0    0    0    0    0    0    0  9.495205
   [5,]    0    0    0    0    0    0    0    0    0  9.674356
   [6,]    0    0    0    0    0    0    0    0    0 10.810197
   [7,]    0    0    0    0    0    0    0    0    0 10.337517
   [8,]    0    0    0    0    0    0    0    0    0  9.715229
   [9,]    0    0    0    0    0    0    0    0    0  9.902603
  [10,]    0    0    0    0    0    0    0    0    0  8.972656
  </code></pre>