I have data representing transactions from a shop. Each basket or person has a line of data for each item bought. Basket sizes can range from 1 to many. The data is sorted by Till Slip which identifies the unique baskets. Simplistic example shown below. My issue - how to calculate [basically identify baskets] using logic. In this example I have 3 baskets - 1, 2, 3 with basket sizes of 3, 2, 3. I want to know which baskets have items b & c in them and flag them yes or no.
How do I apply logic over selected rows - within basket? Would ideally want to do it within the tidyverse / rstudio space.
Who has products b&c in their repertoire?
Answer TillSlip # 1 & 3
TillSlip Item Flag
1 a yes
1 b yes
1 c yes
2 b no
2 d no
3 a yes
3 c yes
3 b yes
etc