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)
}
}
and I need to caculate A2
base on A and X1(4500*4500).Here are the codes
A2<-matrix(4500,500)
for(i in 1:4500){
for(j in 1:500){
A2[i,j]<-(A[X1[i,2],j]+A[X1[i,3],j])/2
}
}
and error happened like this:Error in A2[i, j] <- (A[X1[i, 2], j] + A[X1[i, 3],
j])/2 : subscript out of bounds
I check the criculation number in for loop and it is perfect match with the
dimension of matrix A and X1. I do not know how this error happened? And anther
inportant question is that how can I build a matrix with very larger dimension
which can not allocate in R£®Error in matrix(, 45500, 45500) : cannot allocate
vector of length 2070250000
I am looking forward to hear from you
Kindest Regards
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.