[R] question for loop on matrix row level.

2003-08-19 Thread Lily
For the 1000 simulations, a matrix will be generated each time. And, I need to choose the first row of the generated matrix. The following loop doesn't work though: for (i in 1:1000) { aval[i]- matrixname[1,] } Any solution? thanks! __ [EMAIL

Re: [R] question for loop on matrix row level.

2003-08-19 Thread Spencer Graves
Have you considered making aval an array with the same number of columns as matrixname? Try the following: aval - array(NA, dim=c(2,2)) for(i in 1:2){ matrixname - array(i+(1:4), dim=c(2,2)) aval[i,] - matrixname[1,] } aval hope this helps. spencer graves Lily wrote: For the