title: replace a vector of pattern with another vector in R
body: <p>I have a situation like this,</p>
  
  <pre class="lang-r prettyprint-override"><code>a &lt;- c("abc", "bcd", "def")
  b &lt;- c("pqr", "rat", "xyz")
  c &lt;- c("abc", "def", "abc", "bcd", "bcd", "abc", "def", "abc", "bcd")
  </code></pre>
  
  <p>I want a vector <code>d</code> (say) with each <code>c</code> replaced by values in <code>b</code> that matches <code>a</code>. In shortcut, I need this vector,</p>
  
  <pre><code>"pqr" "xyz" "pqr" "rat" "rat" "pqr" "xyz" "pqr" "rat"
  </code></pre>
  
  <p>I can do <code>gsub</code> by searching each individual string, but how can I do with all of them together.</p>