Newbie question. How to calculate the value of the formula A f B, where f - the binary function OR or AND?
The *AND operator indicates that both operands (on either side of the operator) have to be true to produce a true result. The *OR operator indicates that one or the other of its operands must be true to produce a true result.
Moreover, logical operators allow us to change or compare the results. There are various types of operators available in R, and logical is one of them; we will talk about the OR operator. The OR is a built-in R logical operator that returns TRUE if one of the conditions is TRUE. If both conditions are FALSE, then it will return FALSE.
It is the type of operator (*AND or *OR) that characterizes the expression as logical, not the type of operand. Operands in logical expressions can be logical variables or other expressions, such as relational expressions.
The *OR operator indicates that one or the other of its operands must be true to produce a true result. Note: Using the ampersand symbol or the vertical bar can cause problems because the symbols are not at the same code point for all code pages.
There is a distinction between the conditional operators && and || and the boolean operators & and |. Mainly it is a difference of precendence (which operators get evaluated first) and also the && and || are 'escaping'. This means that is a sequence such as...
cond1 && cond2 && cond3
If cond1 is false, neither cond2 or cond3 are evaluated as the code rightly assumes that no matter what their value, the expression cannot be true. Likewise...
cond1 || cond2 || cond3
If cond1 is true, neither cond2 or cond3 are evaluated as the expression must be true no matter what their value is.
The bitwise counterparts, & and | are not escaping.
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With