Linking Transaction Records in R

Hi, can you provide a repoducible example of your dataset and of what the output should be?