When I write the following code I get a weird answer with &
:
x <- 5
y <- 4
z <- 2
x & z > y
z & x > y
x | z > y
z | x > y
When I run it, the following comes as a result:
[1] FALSE [1] TRUE [1] TRUE [1] TRUE
The &
operator is not giving the same FALSE
answer as it should do when I swap x
and y
, why is that (note when I use brackets everything comes in order correctly)?
I was expecting the first two answers to be FALSE
as one of the variables are smaller than y
and both should be larger than y
when I use &
.
MoE Kurdi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.