title: What would be the best approach for grouping data according to a table of keywords in R
body: <p>I have the following dictionary for grouping data</p>
  <pre><code> 1. [aa11, aa21, aa31, aa34],      &quot;group A&quot;
   2. [x23z, x22z, x32z, x35z, x34z],&quot;group B&quot;
   3. [lg32z, lg22z, lg84x, lg94y],  &quot;group C&quot;
   4. ...
  </code></pre>
  <hr />
  <p>The column in the data itself may also have more than one code. What I want is use the dictionary above and assign the groups to the data:</p>
  <pre><code> 1. [aa31, aa34], &quot;group A&quot;
   2. [lg94z],      &quot;group C&quot;
   3. [lg84x],      &quot;group C&quot;
   4. [x22z, x23z]  &quot;group B&quot;
  </code></pre>
  <p>What would be the best way to assign the records to the specific group described in the first table.</p>
  <p>My thoughts so far:
  Should the data be first reshaped (tokenized) to have one code per record in both the &quot;dictionary&quot; table and the processed table?</p>