Possible Duplicate:
R: subset() logical-and operator for chaining conditions should be & not &&
What is the difference between short (&,|) and long (&&, ||) forms of AND, OR logical operators in R?
For example:
x==0 & y==1x==0 && y==1x==0 | y==1x==0 || y==1
I always use the short forms in my code. Does it have any handicaps?
&and|– are element-wise and can be used with vector operations, whereas,||and&&always generate singleTRUEorFALSEtheck the difference:
So,
&&and||are commonly used inif (condition) state_1 else state_2statements, asdealing with vectors of length
1