Logical

Logical Operators

 x < y  True if x is less than y
 x > y  True if x is greater than y
 x <= y  True if x is less than or equal to y
 x >= y  True if x is greater than or equal to y
 x == y  True if x is equal to y
 x != y  True if x is not equal to y

 x AND y  x && y
 x OR y  x || y
 x XOR y  xor(x,y)
 NOT x  !x

    
  
     





Examples

IDs <- which(v > 10)  

idx = is.na(..)   # find NA's; idx is logical index vector
!idx                   # not ...   (invert logicals of idx)
idx = !is.na(..)  # both together

is.finite - (elements not infinite and not missing)
is.finite(..)




 
 
 
 
Comments