title: Dictionary style replace multiple items
body: <p>I have a large data.frame of character data that I want to convert based on what is commonly called a dictionary in other languages.</p>
  
  <p>Currently I am going about it like so:</p>
  
  <pre><code>foo &lt;- data.frame(snp1 = c("AA", "AG", "AA", "AA"), snp2 = c("AA", "AT", "AG", "AA"), snp3 = c(NA, "GG", "GG", "GC"), stringsAsFactors=FALSE)
  foo &lt;- replace(foo, foo == "AA", "0101")
  foo &lt;- replace(foo, foo == "AC", "0102")
  foo &lt;- replace(foo, foo == "AG", "0103")
  </code></pre>
  
  <p>This works fine, but it is obviously not pretty and seems silly to repeat the <code>replace</code> statement each time I want to replace one item in the data.frame.</p>
  
  <p>Is there a better way to do this since I have a dictionary of approximately 25 key/value pairs?</p>