title: How to create a variable where the value is taken from another variable matching values of a vector
body: <p>I have a dataframe with a variable that is composed of strings of product's names.
  Ex.:</p>
  <pre><code>| Names                       | Price ...|
  |-----------------------------|----------|
  | milk                        | ...      |
  | pizza with tomato           | ...      |
  | tuna with olive and beans   | ...      |
  | etc...                      | ...      |
  </code></pre>
  <p>I would like to create an other variable that take as values names stored in a vector that match those in variable <code>Names</code></p>
  <p>Basically, if I have a vector:</p>
  <pre><code>x &lt;- c(&quot;milk&quot;, &quot;pizza&quot;, &quot;tuna&quot;)
  </code></pre>
  <p>The code should look into the variable <code>Names</code> and if it finds a match in vector <code>x</code> then it takes that value and stores it in a new variable called <code>tag</code> that should have as values <code>milk</code>, <code>pizza</code>, <code>tuna</code>.</p>
  <p>Is it possible to create a variable whose values are taken from another variable if conditions are met?</p>