I am new to R and am having issues figuring out how to create a new dataset from 2 already existing datasets that I have.
I have two datasets that look like this, with different/identical MRNs
- MRN Age Status
- 222 50 likely
- 345 64 likely
- 555 75 unknown
- 888 56 likely
- 675 52 unknown
Second Dataset
- MRN Age Status
- 222 50 likely
- 446 35 unknown
- 555 75 unknown
- 888 56 likely
- 678 48 unknown
I wanted to find the identical MRN's that matched up between both datasets. So I used:
MatchedMRN <- intersect(Tissue$MRN, ctDNA$MRN)
but now I would like to create a new dataset with the matched MRN values, but also with all the other variable/columns in the original 2 datasets that go along with those MRN values. Is there anyway to do this in R?
Thank you!