First we have a transaction data, we can use the built in dataset.
require(arules)
## Can use built-in example dataset
require(datasets)
data(Groceries)
groceries <- as ( "transactions") # convert to 'transactions' class
summary(groceries)
And the output is:
most frequent items:
whole milk other vegetables rolls/buns soda yogurt (Other)
2513 1903 1809 1715 1372 34055
But then we have another data table that we want to data use for labeling:
itemnum <- c(1,2,3,4,5)
ProductName_ <- factor(c("whole milk", "other vegetables", "rolls/buns", "soda", "yogurt"))
ProductNames <- data.frame(itemnum, ProductName_)
How can I replace the product description on the first table with the itemnum from the second?
So when I run:
summary(groceries)
The output is:
most frequent items:
1 2 3 4 5 (Other)
2513 1903 1809 1715 1372 34055