I have two data frames that show data from the two sides - what amount each companies are declared to each other.
From data frame RSX - Partner_company_ID is equal meaning what shows in the second data frame PSX - ID_company and data frame RSX ID_company is the same meaning from data frame PSX - Partner_company_ID.
My task is that in one data frame I add a certain company's declared values to certain partner.
I find this code to lookup values in Data frame PSX to get the right partners amount in data frame RSX, but I realize some problem.
This code manages in RSX data frame to get the right declared value from PSX data frame, but the problem is that I don't know any function that gets the right company's value from RSX data frame ID_company with the right Partner_company_ID from PSX data frame.
Also there is the problem that partner companies have the ability to repeat ID_companys. For example, from RSX data frame ID_company there would be many partners like the company is two partners of 1 and 2 companies with declared values of 10 EUR and 20 EUR.
RSX <- data.frame(ID_company=c(1,1,2,3,4,5,6), Declared_amount_EUR=c(10,20,30,40,50,60,70), Partner_company_ID=c(1,2,3,5,2,7,2)) PSX <- data.frame(ID_company=c(1,2,3,4,5,6), Declared_amount_EUR=c(10,20,35,39,55,61), Partner_company_ID=c(1,1,2,3,4,5)) PS_EURXX <- rep(NA, 7) RSX <- data.frame(RSX, PS_EURXX) RSX$PS_EURXX <- PSX$Declared_amount_EUR[match(RSX$Partner_company_ID, PSX$ID_company)]
Is there any way to make that in the same time I have the ability to manage to get the lookup in the same time with mutiple criteria like a function that checks if the RSX partner company ID is the same as from PSX data frame ID_companys, and at the same time that from RSX ID_company is the same with PSX data frame Partner_company_ID?
I just started learning R language so I will appreciate your help!