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?