I have sales data ie info of what items consumers have bought. I would need to turn it into transactions data for affinity analysis.
Data is like this:
ID=c("A123","A123","A123","A123","B456","B456","B456")
item=c("bread", "butter", "milk", "eggs", "meat","milk", "peas")
data.frame(cbind(ID, item))
ID item
1 A123 bread
2 A123 butter
3 A123 milk
4 A123 eggs
5 B456 meat
6 B456 milk
7 B456 peas
But how could I get it into this form?:
ID basket
A123 bread,butter,milk,eggs
B456 meat,milk,peas