title: R switch statement on comparisons
body: <p>I'm trying to write an R script to evaluate different expressions based on fitting a value within ranges. The idea is that if Length is within one range, it will get evaluated one way, and if it's in a longer range it will get evaluated differently. </p>
  
  <p>I can make this work with if/else statements, but it's pretty ugly, and I'm sure there must be a better way... here's code that works.</p>
  
  <pre><code>Length=8.2
  
  if (Length&lt;1) 
      mode="Walk"
  else if (1&lt;=Length &amp; Length &lt;5)
      mode="bike" 
  else if (5&lt;=Length &amp; Length &lt;10)
      mode="drive"
  else if (Length&gt;=10)
      mode="fly"
  </code></pre>
  
  <p>I've been trying to make something work with the switch function, but it seems to only work with text or integers... is there a way to have a switch statement that conducts evaluations at each case such as this?</p>
  
  <pre><code>Length=3.5
  
  switch(Length,
         (Length&lt;1)  mode="Walk"
         (1&lt;=Length &amp; Length &lt;5)  mode="bike"
         (5&lt;=Length &amp; Length &lt;10)  mode="drive"
         (Length=&gt;10)  mode="fly"
  )
  </code></pre>