title: How do I update data from an incomplete lookup table?
body: <p>I have a table that uses unique IDs but inconsistent readable names for those IDs. It is more complex than month names, but for the sake of a more simple example, let's say it looks something like this:</p>
  
  <pre><code>demo_frame &lt;- read.table(text=" Month_id Month_name Number
  1   Jan 37
  2   Feb 63
  3   March   9
  3   Mar 150
  2   February    49", header=TRUE)
  </code></pre>
  
  <p>Except that they might have spelled "Feb" or "March" eight different ways. I also have a clean data frame that contains consistent names for the names that have variations:</p>
  
  <pre><code>month_lookup &lt;- read.table(text=" Month_id Month_name
  2   Feb
  3   Mar", header=TRUE)
  </code></pre>
  
  <p>I want to get to this:</p>
  
  <pre><code>1   Jan 37
  2   Feb 63
  3   Mar 9
  3   Mar 150
  2   Feb 49"
  </code></pre>
  
  <p>I tried <code>merge(month_lookup, demo_frame, by = "Month_id")</code> but that dropped all the January values because "Jan" doesn't exist in the lookup table:</p>
  
  <pre><code> Month_id Month_name.x Month_name.y Number
  1        2          Feb          Feb     63
  2        2          Feb     February     49
  3        3          Mar        March      9
  4        3          Mar          Mar    150
  </code></pre>
  
  <p>My read of <a href="https://stackoverflow.com/questions/30654065/how-to-replace-data-frame-column-names-with-string-in-corresponding-lookup-table">How to replace data.frame column names with string in corresponding lookup table in R</a> is that I ought to be able to use <code>plyr::mapvalues</code> but I'm unclear from examples and documentation on how I'd map the <code>id</code> to the <code>name</code>. I don't just want to say "Replace 'March' with 'Mar'" -- I need to say <code>SET month_name = 'Mar' WHERE month_id = 3</code> for each value in lookup. </p>