I have two data frames D1 and D2 as mentioned below
I want to compare D1 and D2 like "Issues" of D1
with "list_of_issues" of D2
ID = c(1, 2, 3, 4)
Issues = c('CI', 'E,CI', 'H,A', 'CI,E')
Location = c('x', 'y', 'z', 'w')
Customer = c('a', 'b', 'c', 'd')
D1 = data.frame(ID, Issues, Location, Customer)
Root_Cause = c('R1', 'R2', 'R3', 'R4')
List_of_Issues = c('A', 'A,H', 'E,CI', 'CI')
D2 = data.frame(Root_Cause, List_of_Issues)
if issues are matching with the root cause then obtain the Root_cause
in D3
by generating a column Root_Cause
like this in D3
ID = c(1, 2, 3, 4)
Issues = c('CI', 'E,CI', 'H,A', 'CI,E')
Location = c('x', 'y', 'z', 'w')
Customer = c('a', 'b', 'c', 'd')
Root_Cause = c('R4', 'R3', 'R2', 'R3')
D3 = data.frame(ID, Issues, Location, Customer, Root_Cause)