[R] Sincere inquiry about “subscript out of bounds” error in R

2012-04-06 Thread 卢永芳
Hello£¬experts I am working on a simulation of effect of artificial selection on certain population in Animal Breeding.I am new beginner in coding. I have already build a matrix A(500*500) based on this code A-matrix(,500,500) for(i in 1:500){ for(j in 1:500){ ifelse(i==j,A[i,j]-1,A[i,j]-0) } }

Re: [R] Sincere inquiry about “subscript out of bounds” error in R

2012-04-06 Thread jim holtman
You need to do some basic debugging by putting options(error=utils::recover) in your startup of R (or just type it in) so that when the error occurs you get control at the point of the error and can examine all the variable. You have some incorrect data that is causing the subscript error, so

Re: [R] Sincere inquiry about “subscript out of bounds” error in R

2012-04-06 Thread Henrik Bengtsson
str() is your number one friend in R. Do str(A) and str(A2) after allocating the matrices and you'll be surprised. My $.02 /Henrik On Fri, Apr 6, 2012 at 7:35 AM, 卢永芳 sswwss...@126.com wrote: Hello,experts I am working on a simulation of effect of artificial selection on certain population