title: R, missing value where TRUE/FALSE needed
body: <p>I trying to check if two variables have the same sign this is the code I am using.</p>
  
  <pre><code>a &lt;- c(0)
  x1 &lt;- x/abs(x)
  y1 &lt;- y/abs(y)
  if(x1==y1) {
    a &lt;- x + y
    } else {
    a &lt;- x - y
  }
  </code></pre>
  
  <p>But I get the error</p>
  
  <pre><code>Error in if (x1 == y1) { : missing value where TRUE/FALSE needed
  </code></pre>
  
  <p>What am I doing wrong? Is there a more efficient way to check the signs?</p>