Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201945

Merge two data sets with indicator variable on Non-merges

$
0
0

I have two data sets. Lets call them Master data and Using data. I merged the using data into the master data using 3 keys. I included the all=TRUE argument to keep all merged and non-merged observations

merged_data <- merge(dataset1, dataset2, by=c("key1","key2","key3"), all=T)

Now my question. How do I get information on whether a non-merge happened in Master data or the Using data? Ideally, I want a column that has value

1) 1 if non merge happened due to Using data 2) 2 if non merge happened due to Master Data 3) 3 if Successful Merge!!

Thanks, Kedar


Viewing all articles
Browse latest Browse all 201945

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>