Displaying 1 result from an estimated 1 matches for "fi_2".
Did you mean:
f3_2
2011 Mar 15
1
Matrix building to remove for loops
Hello R users,
I would like to reduce the number of for loops in my code. I build these
matrices (50000 times). The main diagonal are 1s and the two sides along the
main diagonal mirror each other as follows:
i<-5
fi<-matrix(0,nrow=i,ncol=i)#floral inhibition matrix for(r in 1:i){ for(c in
1:i){ if(r==c){ fi[r,c]<-1 }else if(r<c){ fi[r,c]<-1-runif(1)^.5 }else{
fi[r,c]<-fi[c,r]