I would like to generate indexes for grouping observations based on two columns. But I want the groups to be made observations that share at least one observation in the community. I see how to create observation-based groups that share a common observation, but not just one of them.
For example, with a data frame:
dt <- data.frame(id=1:10, G1 = c("A","A","B","B","C","C","C","D","E","F"), G2 = c("Z","X","X","Y","W","V","U","s","T","T"))
I would like to get a column
1,1,1,1,2,2,2,3,4,4
I tried using group_indices from dplyr but could not execute it.
r dplyr
Malta
source share