title: change all strings in dataframe to one of several different values r (NOT a duplicate)
body: <p>(see "<strong>IMPORTANT</strong>" note below - question is not solved by the answers to a similar post; it's <strong>not</strong> a duplicate)</p>
  
  <p>I have a bunch of dataframes with a ton of vectors containing the same two likert scales that I need to recode from strings (currently as factors) to numeric values (1 to 5). Here are the scales:</p>
  
  <pre><code>Likert scale A:
  ---------------
  Terrible      = 1
  Below Average = 2
  Average       = 3
  Above Average = 4
  Excellent     = 5
  
  
  Likert Scale B:
  ---------------
  Strongly disagree = 1
  Somewhat disagree = 2
  Meh               = 3
  Somewhat agree    = 4
  Strongly agree    = 5
  </code></pre>
  
  <p>As an example, here is <code>HAVE1</code>, one of the many datasets (each of which have a different number of vectors and different vector names) with these likert patterns:</p>
  
  <pre><code>Apples        Oranges       Bananas       ServiceGood       ShortTime
  Excellent     Terrible      Average       Somewhat agree    Somewhat agree
  Excellent                   Above Average Strongly agree    Somewhat agree
  Above Average Terrible      Below Average                   Somewhat disagree
  Excellent     Average       Below Average Meh               Strongly disagree
  Below Average Terrible      Above Average Somewhat agree    Meh
  …             …             …             …                 …
  </code></pre>
  
  <p>I need to replace the character strings with a numeric equivalent from the likert scale codes listed above. For example, the first 5 observations of <code>WANT1</code> should look like this:</p>
  
  <pre><code>Apples  Oranges Bananas ServiceGood ShortTime
  5       1       3       4           4
  5       NA      4       5           4
  4       1       2       NA          2
  5       3       2       3           5
  2       1       4       4           3
  …       …       …       …           …
  </code></pre>
  
  <p>I'm looking for efficient ways to modify these values that don't require any invocation of vector names due to the differences in names and positions across all my <code>HAVE</code> dataframes. Any thoughts?</p>
  
  <p><strong>IMPORTANT:</strong> this problem is NOT solved by any of the examples provided in the question "<a href="https://stackoverflow.com/questions/7547597/dictionary-style-replace-multiple-items">Dictionary style replace multiple items</a>"; every answer throws an error of some sort or fills the values of most variables with NA/replaces the wrong values.</p>
  
  <p>For example, the following code...</p>
  
  <pre><code>map = setNames(c("Excellent", "Above Average", "Below Average", "Average", "Terrible"), 
                 c("5", "4", "2", "3", "1"))
  HAVE1[] &lt;- map[unlist(HAVE1)]
  </code></pre>
  
  <p>Sets every value in my file to NA except for the empty cells, which it codes to "Terrible". The only solution from the other question that works in the "dictionaries" answer is the solution proposed in the question itself by the asker - it is this very approach that the asker hoped to avoid.</p>