I'm doing cross-sell analysis for several products with R. I've already transformed the transactional data and it looks like this -
df.articles <- cbind.data.frame(Art01,Art02,Art03)
Art01 Art02 Art03
bread yoghurt egg
butter bread yoghurt
cheese butter bread
egg cheese NA
potato NA NA
Actual data is 'data.frame': 69099 obs. of 33 variables.
I want to have the list of all distinct articles and their counts that was sold with an Article(say bread or yoghurt in this case) Actual data consists of 56 articles for which I need to check all the articles with which it was cross-sold. So the results that I would want to have has to be look like -
Products sold with **bread** Products sold with **Yoghurt**
yoghurt 2 bread 2
egg 1 egg 1
cheese 1 butter 1
butter 1
.... and list goes on like this for say 52 different articles.
I've tried couple of things but it is too manual for this big dataset. It would be great to have this problem solved with the help of library(data.table), if not, that shall also be very fine. Thank you very much in advance.