title: Replacing elements in a dataframe not contained in a vector
body: <p>Simple problem, but I couldn't find a solution: How to replace all elements in a dataframe not contained in a vector with a specific string?</p>
  
  <p>My dataframe looks like this:</p>
  
  <pre><code>ID &lt;- sample(1:8)
  Country &lt;- c("USA", "RUS", "Unknown", "Not specified", "???", "XXX", "FRA", "ITA")
  myDF &lt;- data.frame(ID, Country)
  </code></pre>
  
  <p>I also have a vector that contains all possible country codes:</p>
  
  <pre><code>countryCodes &lt;- c("ESP", "FRA", "ITA", "GBR", "DEU", "USA", "RUS", "BRA", "KOR", "BLZ", "BLR", "BEL", "TWN", "CHN")
  </code></pre>
  
  <p>I would like to replace all elements in myDF$Country not contained in countryCodes with "N/D".</p>
  
  <p>The dataset I'm working with has around 30 million rows and I have to perform several transformations, so I'd like to keep the code simple and as quick as possible.</p>
  
  <p>Thanks in advance!</p>