I would like to generate indices to group observations based on two columns. But I want groups to be made of observation that share, at least one observation in commons. I can see how to make groups based on observations that share both observation in common, but not just one of them.
For example, with the 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 with group_indices from dplyr, but haven't managed it.
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…