We are almost there! There is an extra step that we need to do in order to prepare our data for market basket analysis.
The association rules package requires that the data be in transaction format. Transactions can either be specified in two different formats:
- One transaction per itemset with an identifier and this shows the entire basket in one line, just as we saw with the Groceries data.
- One single item per line with an identifier.
Additionally, you can create the actual transaction file in two different ways, by either:
- Physically writing a transactions file.
- Coercing a dataframe to transaction format.
For smaller amounts of data, coercing the dataframe to a transaction file is simpler, ...