title: Using if else statement for multiple conditions
body: <p>Sample data:</p>
  
  <pre><code>x&lt;-runif(100, min=0, max=1)
  y&lt;-runif(100, min=0, max=1)
  dif&lt;-x-y
  dat&lt;-data.frame(x,dif)
  </code></pre>
  
  <p>What I want to do is to create another column in data frame <code>dat</code> called <code>suit</code>. If <code>x</code> is less than 0.15 and <code>dif</code> is less than 0, than <code>suit</code> should have a value of 3. If <code>x</code> is less than 0.15 and <code>dif</code> is greater than 0, than <code>suit</code> should have a value of 2 and if <code>dif</code> is greater than 0, than <code>suit</code> has value of 1. </p>
  
  <p>This is the code that I am prepared. </p>
  
  <pre><code>if(dat$x&lt;0.15 &amp; dat$dif&lt;0){
     dat$suit&lt;-3
  } else {
  if(dat$x&gt;=0.15 &amp; dat$dif&lt;0){
     dat$suit&lt;-2  
  } else {
    dat$suit&lt;-1  
   }
  }
  </code></pre>
  
  <p>It gives all the values of <code>dat$suit</code> as 1. I am not sure what I am doing wrong here. </p>
  
  <p>Thank you for your help.</p>