I have read
http://stat.ethz.ch/R-manual/R-devel/library/base/html/Logic.html
and the difference between & and && doesn't make sense. For example :
> c(1, 2, 3) & c(1,2,3)
[1] TRUE TRUE TRUE
According to the link this is expected behavior. It is doing an element-wise comparison of the two vectors.
So I test again...
> c(1, 2, 3) && c(1,2,3)
[1] TRUE
This also returns what was expected.
But then I change a value...
> c(1, 2, 3) && c(1,3,3)
[1] TRUE
Still expected because it short circuits on the first element.
> c(1, 2, 3) & c(1,3,3)
[1] TRUE TRUE TRUE
This however lost me. These two vectors should not be equal.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…