So I have a data frame that contains a bunch of transactions with items, kinda like this:
| 1 | 2 | 4 | 5 | 6 |
| 3 | 5 | 8 | 9 | |
| 1 | 5 | 7 | 10 | 12 |
| 7 | 8 | 10 | 15 | 17 |
I have a list of all the existing items, and now I'd like to convert this to a logical matrix with 0 and 1 values. So if an item exists in a given row, that entry in the matrix should be 1.
Is there an easy way to do this?
Edit : For the logical matrix, we need to generate a column for each item, and a row for each transaction.