0

I am trying to do a basic lookup in R and I'm getting multiple matches, instead of just one. It seems to be working like a left join, or right join, in SQL if I join on an ID that appears more than once.

I am importing data from two Excel sheets.

Sheet1 looks like this:
CATEGORY    CUSTOMER_NO
21050   1154010
71090   1154010
87050   1154010

Sheet2 looks like this:
CUSTOMER_NO  DEALLOCALBAL 
1154010  $1,433,175.05 

I tried each of these:

Outer<-merge(x = analysisAdj, y = mappingAdj, by = "CATEGORY", all = TRUE)
LOuter<-merge(x = analysisAdj, y = mappingAdj, by = "CATEGORY", all.x = TRUE)
ROuter<-merge(x = analysisAdj, y = mappingAdj, by = "CATEGORY", all.y = TRUE)

Each time the record count in increasing because of multiple matches, and then I have 1433175.1 three times. How can I simply do a vlookup to pull in one single match, even when the CUSTOMER_NO repeats multiple times? Thanks.

ASH
  • 20,759
  • 19
  • 87
  • 200
  • Duplicate question: [https://stackoverflow.com/questions/1299871/how-to-join-merge-data-frames-inner-outer-left-right](https://stackoverflow.com/questions/1299871/how-to-join-merge-data-frames-inner-outer-left-right) – David Klotz Jan 30 '18 at 18:44
  • Ah. Now I see how it works. Thanks. – ASH Jan 30 '18 at 22:35

0 Answers0