If strings of two dataframes match return rownames of matching

Hi, I have looked at all the similar questions on any platforms but have not found a solution to my problem.

I made a thesaurus with synonyms. This is my first dataframe. The rownames are very important and should be printed if any synonym matches with the second dataframe.
It looks like this:

                     Synonym                        Synonym2            Synonym3
0010                      01                      beobachten                   U
0030                     hkp                            <NA>                <NA>
0040                     hkp                            <NA>                <NA>
0050                    <NA>                            <NA>                <NA>
0060                    <NA>                            <NA>                <NA>
0065                    <NA>                            <NA>                <NA>
0070                    vipr                            perk                <NA>
0080           oberfl anästh                anästh                <NA>
0090                vest inj                        vest inj       inj sept blau
0100                      l1                            <NA>                <NA>
0110                    <NA>                           üz                  <NA>
0120                    <NA>                       <NA>                <NA>
1000       gezeigt zu achten                       putzdruck                 mhu

my second dataframe is a transcript of what was done at the dentist.
It looks like this:

   ID     Aufzeichnungen
1   1       scharfkantig
2   1                  t
3   1          üz distal
4   1     seit paartagen
5   1            36 vipr
6   1              hahn
7   1          bilfuird

Logically it should match "0070 vipr" and "0110 üz" of my thesaurus with row 3 and 5 of my second dataframe.
As output it should return the rownames (0070, 0110) of the thesaurus.

My code was:

a <- thesaurus[grep(PKV_clean$Aufzeichnungen,rownames(thesaurus))]

But this did not work as planned.

I'm desperate. So thank you in advance. I owe you a lot!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.