How can I group rows that have names in different order in R?

55 Views Asked by At

I have two data frames in R, both share a "NAME" column. I want to merge them by the NAME column, however I have the next problem:

In the DataFrame A, the names in the NAME column have this format: Anna Thompson Brown
However, in the DataFrame B some names follow the A format, but some others are like this: Thompson Brown Anna. An important note is that all names have two surnames, and some of them two names (e.g. Anna Mary Thompson Brown)

Is there a way to convert all the names to the same format? or maybe a way to merge the DataFrames even thought the names have a different order?

I haven't tried anything yet, im lost, so I would really appreciate your help!

0

There are 0 best solutions below