This question already has an answer here:
- R - boolean operators && and || 3 answers
I am writing a complex if statement in R involving comparing the numeric value of three different number vectors to a given number.
However I don't fully understand the difference between & and &&.
What is the difference between these four:
a[i] > 30 && b[i] > 30 && c[i] > 30
a[i] > 30 & b[i] > 30 & c[i] > 30
a[i] > 30 & b[i] > 30 && c[i] > 30
a[i] > 30 && b[i] > 30 & c[i] > 30
Also I don't fully understand the same situation with | and ||. For instance, what is the difference between:
a[i] > 30 & b[i] > 30 || c[i] > 30
and the following?
a[i] > 30 & b[i] > 30 | c[i] > 30
Any help would be greatly appreciated! My question is about an if statement with three conditions so previous posts haven't fully addressed this.
Aucun commentaire:
Enregistrer un commentaire