title: R language: switch cases on numeric value
body: <p>I want to switch cases in numeric value, but I can't find a natural way to do this. Here's what I tried:</p>
  
  <p>this leads to syntax error:</p>
  
  <pre><code>fun &lt;- function(x) {
      switch(x,
             0.2=0.1,
             0.9=0.6)
  }
  </code></pre>
  
  <p>this one compiles, but is there a better solution?</p>
  
  <pre><code>fun &lt;- function(x) {
      y &lt;- as.character(x)
      switch(y,
             "0.2"=0.1,
             "0.9"=0.6)
  }
  </code></pre>