title: r error occurs in statement with else but not in if statement
body: <p>My data set contains numeric values with decimals </p>
  
  <p>When I write a simple if statement like this:</p>
  
  <pre><code>data$Segment &lt;- ifelse(data$RankAll&gt; 10,'Gekko',0)
  </code></pre>
  
  <p>I do not get an error but when I write it like this:</p>
  
  <pre><code>data$Segment &lt;- if (data$RankAll&lt;4) 'Moore' else if 
                     (data$RankAll&lt;6) 'Marvin' else if
                     (data$RankAll&lt;8)'Branes' else if 
                     (data$RankAll&lt;10) 'Fox' else 'Gekko'
  </code></pre>
  
  <p>It returns the error:</p>
  
  <pre><code>Warning messages:
   1: In if (data$RankAll &lt; 4) "Moore" else if (data$RankAll &lt; 6) "Marvin" else if (data$RankAll &lt;  :
    the condition has length &gt; 1 and only the first element will be used
  2: In if (data$RankAll &lt; 6) "Marvin" else if (data$RankAll &lt; 8) "Branes" else if (data$RankAll &lt;  :
    the condition has length &gt; 1 and only the first element will be used
   3: In if (data$RankAll &lt; 8) "Branes" else if (data$RankAll &lt; 10) "Fox" else "Gekko" :
    the condition has length &gt; 1 and only the first element will be used
   4: In if (data$RankAll &lt; 10) "Fox" else "Gekko" :
  </code></pre>
  
  <p>the condition has length > 1 and only the first element will be used</p>
  
  <p>What am I doing wrong?</p>