Linking Transaction Records in R

We need to write a code to map out the following scenario:

We have the following fields in our table Customer Number, Transaction ID, Return ID. Customer A makes a purchase on May 5. The transaction comes in but there is no customer number associated with the transaction (so only transaction ID is populated). This customer eventually ends up coming back again on May 10 to make another purchase and return the items originally purchased on May 5. Once again, we see the transaction in the db and return ID field is also populated with the same value as the original May 5 transaction. But no customer number. The customer returns again on June 1 to return the items bought on May 10 and this time we see a customer number. Since the return ID field is populated with the transaction ID from May 10, we can use this information to update the customer numbers in the previous records. This way we can trace the customer's purchase history with us.

Is there a quick way to map the above process out in R?

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


Here is an example dataset of transactions that can be linked to each other by seeing if transaction_ID_SHORT matches return_original_transaction ID short:

The output is to

  1. Identify and group the linked transactions.
  2. Sort the grouped transactions by date_transaction_processed by older to newer.
    Here is an example of what the output might look like:

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.