title: Renaming/Recoding variables efficiently
body: <p>I'm using R and have a dataset with ~3000 psychological test data. Most of the data is stored as string variables:</p>
  <pre><code>&gt; table(rona_full$FQ169_6)
  
               At no time        Some of the time Less than half the time More than half the time 
                      418                      73                      48                      36 
         Most of the time         All of the time 
                       20                       9 
  </code></pre>
  <p>I want to recode the string data into variables as such:</p>
  <pre><code>&gt; table(rona_full$FQ169_6)
  
    0   1   2   3   4   5 
  443  63  39  30  21   9 
  </code></pre>
  <p>Currently, this is my approach:</p>
  <pre><code>rona_full$FQ169_6 &lt;-ifelse(rona_full$MQ169_6 == &quot;At no time&quot;, 0, #this recodes MDI from string
                      ifelse(rona_full$MQ169_6 == &quot;Some of the time&quot;, 1,
                      ifelse(rona_full$MQ169_6 == &quot;Less than half the time&quot;, 2,
                      ifelse(rona_full$MQ169_6 == &quot;More than half the time&quot;, 3,
                      ifelse(rona_full$MQ169_6 == &quot;Most of the time&quot;, 4, 5)))))
  </code></pre>
  <p>I imagine there is a more efficient way to perform this exact same recoding on 25+ columns rather than doing each one this way.</p>