title: Difference between quoted vs unquoted keys in switch() in R?
body: <p>In some simple tests I constructed, quoted and unquoted keys in calls to <code>switch()</code> appear to behave the same way.</p>
  <p>E.g.</p>
  <pre><code>value &lt;- &quot;cat&quot;
  
  switch(value,
    cat = { &quot;cat&quot; },
    dog = { &quot;dog&quot; },
    mouse = { &quot;mouse&quot; },
    &quot;unknown&quot;
  )
  # [1] &quot;cat&quot;
  
  switch(value,
         &quot;cat&quot; = { &quot;cat&quot; },
         &quot;dog&quot; = { &quot;dog&quot; },
         &quot;mouse&quot; = { &quot;mouse&quot; },
         &quot;unknown&quot;
  )
  # [1] &quot;cat&quot;
  </code></pre>
  <p>Above we see both <code>cat</code> and <code>&quot;cat&quot;</code> cause the correct code block to be executed.</p>
  <h3>Question</h3>
  <p>Is there any time where quoted vs unquoted keys matter, and if so which of unquoted or quoted is best practice - I am interested in writing robust code and not have to deal with strange anomalies months later, so even subtle quirks matter here.</p>