I am getting an argument of length zero after running the code below. I have looked at other users with this issue, however I am unable to figure out the error.
gi <- pm%*%t(pm); #creates a 5k by 5k matrix by multiplying matrix by its transpose
dim(gi); # checks dimensions of matrix
ngen <- dim(pm)[1];
select <- matrix(F,ncol=ngen,nrow=ngen);
for(i in 1:(ngen-1)){
for(ii in (i+1):ngen){
if(gi[i,ii] < llim){
next;
}
hit1 <- p.sum[i];
hit2 <- p.sum[ii];
if(gi[i,ii] >= qmat[hit1,hit2]){
select[i,ii] <- TRUE;
}
}
}
This code returns the error:
Error in if (gi[i, ii] >= qmat[hit1, hit2]) { :
argument is of length zero
I have a feeling that the problem is the gi variable as hit1 and hit2 return values, any ideas how I could fix it? Any assistance would be greatly appreciated.
The most likely reason for the failure is that
hit1orhit2returns0.…And you can use
tcrossprod(pm)instead ofpm%*%t(pm)– it’s faster and (in my opinion) clearer.