how to match on multiple columns

Hello. I am hoping someone can direct me on this question. I have two data files. I want to be able to pull out records from one file that match records in another file. I want to match on last name, first name, and date of birth. I am thinking it is something like using an %in% statement and create a True/False variable. But I don't know how to do it for multiple columns. I would appreciate if someone could give me a little direction. I did try searching posts and help files, but I just can't quite find what I need.

Thank you.
Amy Riffe

Hello @ARiffe,

What you are asking seems to be something that is not too difficult to do with R. However, it is a bit difficult to tell you exactly what to do since your question does not contain any "reproducible example". In a few words, a reproducible example is one that contains a sample dataset that has all the features you described (it needs not be your actual dataset in case you cannot share due to professional reasons for example) and also the code that you tried, which did not work. I understand that you may not have tried any code and that you are seeking for help. If you could provide sample data (2 datasets in your case), that would help us to help you :slight_smile:. By the way, you may want to look into the dput() function in order to share your data with us. If your data is too big, then subset if by a few rows before sharing:

dput(mydata[1:50, ])

This great article here will provide more information on what a reproducible example is: FAQ: How to do a minimal reproducible example ( reprex ) for beginners

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.