title: Replace whole string referencing a named vector
body: <p>I want to do a partial string match against a named vector, and where it matches, use the named vector as a whole string value.</p>
  <p>appreciate your assistance.</p>
  <pre class="lang-r prettyprint-override"><code>library(tidyr)
  library(stringr)
  map &lt;- tibble(str = c('rolex','mazda','nike'),
                cat = c('watch','car','shoe'))
  df &lt;- tibble(data = c('I love driving mazda','He wears a rolex to work','awesome nike shoe'))
  </code></pre>
  <p>Sample table</p>
  <pre><code>&gt; map
  # A tibble: 3 x 2
    str   cat  
    &lt;chr&gt; &lt;chr&gt;
  1 rolex watch
  2 mazda car  
  3 nike  shoe 
  &gt; df
  # A tibble: 3 x 1
    data                    
    &lt;chr&gt;                   
  1 I love driving mazda    
  2 He wears a rolex to work
  3 awesome nike shoe
  </code></pre>
  <p>Desire results</p>
  <pre class="lang-r prettyprint-override"><code>&gt; df
  # A tibble: 3 x 2
    data                     cat  
    &lt;chr&gt;                    &lt;chr&gt;
  1 I love driving mazda     car  
  2 He wears a rolex to work watch
  3 awesome nike shoe        shoe 
  </code></pre>
  <p>Tried this but it replace the string it found, but not replace the entire string referencing the named vector as above.</p>
  <pre class="lang-r prettyprint-override"><code>map_v = as.character(map$cat)
  names(map_v) = map$str
  </code></pre>
  <p>Unwanted result</p>
  <pre><code>&gt; df %&gt;% mutate(cat = str_replace_all(data,map_v))
  # A tibble: 3 x 2
    data                     cat                     
    &lt;chr&gt;                    &lt;chr&gt;                   
  1 I love driving mazda     I love driving car      
  2 He wears a rolex to work He wears a watch to work
  3 awesome nike shoe        awesome shoe shoe
  </code></pre>