Replace a transaction type data table with item number from a different table using R
<p>First we have a transaction data, we can use the built in dataset. </p>

<pre><code>require(arules)

## Can use built-in example dataset
require(datasets)
data(Groceries)

groceries &lt;- as ( "transactions") # convert to 'transactions' class

summary(groceries)
</code></pre>

<p>And the output is:</p>

<pre><code>most frequent items:
  whole milk other vegetables       rolls/buns             soda           yogurt          (Other) 
        2513             1903             1809             1715             1372            34055 
</code></pre>

<p>But then we have another data table that we want to data use for labeling:  </p>

<pre><code>itemnum &lt;- c(1,2,3,4,5)
ProductName_ &lt;- factor(c("whole milk", "other vegetables", "rolls/buns", "soda", "yogurt"))
ProductNames &lt;- data.frame(itemnum, ProductName_)
</code></pre>

<p>How can I replace the product description on the first table with the itemnum from the second?</p>

<p>So when I run:</p>

<pre><code>summary(groceries)
</code></pre>

<p>The output is:</p>

<pre><code>most frequent items:
     1      2       3      4       5       (Other) 
  2513   1903    1809   1715    1372         34055 
</code></pre>