title: Ifelse() with three conditions
body: <p>I have two vectors:</p>
  
  <pre><code>a&lt;-rep(1:2,100)
  
  b&lt;-sample(a)
  </code></pre>
  
  <p>I would like to have an ifelse condition that compares each value of <code>a</code> with the corresponding value of <code>b</code>, and does the following:</p>
  
  <pre><code>if a&gt;b 1
  if a&lt;b 0
  if a=b sample(1:2,length(a),replace=T)
  </code></pre>
  
  <p>the first two can be done with :</p>
  
  <pre><code>ifelse(a&gt;b,1,0)
  </code></pre>
  
  <p>but I'm not sure how to incorporate the case where <code>a</code> and <code>b</code> are equal.</p>