title: What's the differences between & and &&, | and || in R?
body: <p>Why there are four logical operators:</p>
  
  <pre><code>&amp;, &amp;&amp;
  |, ||
  </code></pre>
  
  <p>What's the differences in usage?</p>
  
  <p>Yes, I've checked the docs, yet I'm a little bit confused. The docs says:</p>
  
  <pre><code> ‘&amp;’ and ‘&amp;&amp;’ indicate logical AND and ‘|’ and ‘||’ indicate
   logical OR.  The shorter form performs elementwise comparisons in
   much the same way as arithmetic operators.  The longer form
   evaluates left to right examining only the first element of each
   vector.  Evaluation proceeds only until the result is determined.
   The longer form is appropriate for programming control-flow and
   typically preferred in ‘if’ clauses.
  </code></pre>
  
  <p>I think a piece of example will clearly demonstrate them. Thanks.</p>