I am trying to classify matrices based on which row has the highest value. My code works correctly, except for when the first and third row have the same value - then the output is that the third value is larger than the first. For example, when I use the following matrix:
        , , 1
           [,1]   [,2]   [,3]
    [1,] 0.5+0i 0.5+0i 0.5+0i
    [2,] 0.0+0i 0.0+0i 0.0+0i
    [3,] 0.5+0i 0.5+0i 0.5+0i 
And the following bit of the code:
  null   <- 0
  neg   <- 0
  pos   <- 0
  equal <- 0
  for(i in 1){
   if(Re(pie.ch[1,1,i])>Re(pie.ch[2,1,i]) &&
      Re(pie.ch[1,1,i])>Re(pie.ch[3,1,i])){
         neg<-neg+1
    }
    if(Re(pie.ch[3,1,i])>Re(pie.ch[1,1,i]) &&
       Re(pie.ch[3,1,i])>Re(pie.ch[2,1,i])){
          pos<-pos+1
    }
  if(Re(pie.ch[2,1,i])>Re(pie.ch[1,1,i]) &&
  Re(pie.ch[2,1,i])>Re(pie.ch[3,1,i])){
      null<-null+1
  }
  if((Re(pie.ch[1,1,i])==Re(pie.ch[2,1,i]) && 
    Re(pie.ch[1,1,i])>Re(pie.ch[3,1,i]))||
    (Re(pie.ch[1,1,i])==Re(pie.ch[3,1,i])&&
    Re(pie.ch[1,1,i])>Re(pie.ch[2,1,i])||
  (Re(pie.ch[2,1,i])==Re(pie.ch[3,1,1])&&
  Re(pie.ch[3,1,i])>Re(pie.ch[1,1,i]))|| 
  Re(pie.ch[1,1,i])==Re(pie.ch[2,1,i]) &&
  Re(pie.ch[2,1,i])==Re(pie.ch[3,1,i]))){
     equal<-equal+1
 }
}
    null
    neg
    pos
    equal
I get the following output, which is clearly wrong:
> null
[1] 0
> neg
[1] 0
> pos
[1] 1
> equal
[1] 0
However, the code works correctly if all the three values are the same (I tried it for all values being 0), giving me a 1 for Equal and a 0 for Pos.
Any ideas why this error might occur? Thank you very much!
 
    