Assign group numbers across all combinations in two columns

17 Views Asked by At

I have used pairwise cosine similarity to compare a bunch of company names and I have all the pairwise matches. I need to assign group numbers that take into account all the combinations, rather than just the first column. Some examples I found that used group_by() gave group numbers based solely on item1, not extending to the rows identified in item2.

Sample data: enter image description here

Desired output is: enter image description here

The output could also just be a column added to the sample data but with unique group numbers across all matched rows.

0

There are 0 best solutions below