Hi,
 
I had the following code:

  testp <- rcorr(t(datcm1),type = "pearson")
  mat1 <- testp[[1]][,] > 0.6
  mat2 <- testp[[3]][,] < 0.05
  mat3 <- mat1 + mat2
 
The resulting mat3 (smaller version) matrix looks like:
 
 NA   0    0    0  
  0  NA    0   NA 
  0   0   NA    2 
  0   0    2   NA   
 
To get to the number of times a '2' appears in the rows, I was trying to run the following code:
 
numrow = nrow(mat3)
  counter <- matrix(nrow = numrow,ncol =1)
  for(i in 1:numrow){
   count = 0;
   for(j in 1:numrow){
    if(mat3[i,j] == 2){
     count = count + 1
    }
   }
          counter[i,1] = count
  }
 
However, I get the following error:
 
'Error in if (mat3[i, j] == 2) { : missing value where TRUE/FALSE needed'
 
I also tried to use the na.action, but couldn't get anything. I'm sure there must be a relatively easy fix to this. Is there a workaround this problem?
 
thanks,
 
Tim
 

__________________________________________________



	[[alternative HTML version deleted]]


