R Cheatsheet: Logical Operators
#Non equal to
#Less than or equal to
#Greater than or equal to
#Negation (NOT operator), or to negate a boolean expression:
#we can use both ‘&’ and ‘&&’ the difference between this two symbols is that the first evaluates ALL the elements of a vector, and the second only the first element of a vector.
#The OR operator follows a similar set of rules. The `|` version of OR evaluates OR across an entire vector, while the `||` version of OR only evaluates the first member of a vector.
#Important!: The rules of precedence dictate that ALL the AND operations are evaluated first, then the OR operations are calculated later.
FALSE && 6 >= 6 || 7 >= 8 || 50 <= 49.5
#The expression from above results in FALSE, because by the rules of precedence we first evaluate FALSE && 6 >= 6 OBTAINING a FALSE, after thaht we evaluate the OR operations resulting in FALSE.
#R has a function to evaluate is an expression is TRUE
#Identical is a function which evaluates if two elements are equal returning TRUE.
#The xor() function stands for exclusive OR. If one argument evaluates to TRUE and one argument evaluates to FALSE, then this function will return TRUE, otherwise it will return FALSE.
#A function that returns the elements of a vector complying with a logical operation:
#Returns TRUE if at least an element of the vector evaluated is TRUE.
#Returns TRUE if all elements are true: