title: assign a value in switch() different from the parameter passed in R
body: <p>I do not fully understand switch() in R, I have seen examples like:</p>
  
  <pre><code>newCat &lt;- switch(EXPR = category,
         cat1   = catX,
         cat2   = catX,
         cat3   = catY,
         cat4   = catY,
         cat5   = catZ,
         cat6   = catZ,
         "not available")
  </code></pre>
  
  <p>But, what I need is, given a parameter, to do something different... </p>
  
  <p>I am trying to rewrite this into a case:</p>
  
  <pre><code>sample&lt;-function(M,meth)
  {
  
    if (meth=="sin_low" || meth=="sin_high")
    {
      d&lt;-samplesin(M)
    }
    if (meth=="GP" || meth ="GP_high")
    {
      d&lt;-sampleGP(M)
    }
    return(d)
  }
  </code></pre>