I have the following data frames
l1=data.frame(c1=c("drug1","drug4","drug2","drug1","drug3","drug9"),c2=c("headache","lung cancer","lymphoma","sprain","depression","ptsd"))
l2=data.frame(x1=c("bone cancer","sprain","lung cancer","headache","ptsd","bipolar","lymphoma","depression"),
group=c("cancers","pain","cancers","pain","mental disorder","mental disorder","cancers","mental disorder"))
I want to map the features in c2 of l1(the first dataframe) to x1 of l2(second dataframe) such that a new column is created which contains the proper group (according to group column in l2) of each feature in c2(first column l1) The output should look something like this `
l3= data.frame(col11=c("drug1","drug4","drug2","drug1","drug3","drug9"),col2=c("headache","lung cancer","lymphoma","sprain","depression","ptsd"),
col3=c("pain","cancers","cancers","pain","mental disorder","mental disorder"))
` Both the dataframes contain a large number of rows Thanks!