I have a dataframe such as
GroupsA GroupsB
G1 G2
G1 G3
G1 G4
G1 G5
G1 G6
G2 G3
G2 G4
G2 G5
G2 G6
G3 G4
G3 G5
G3 G6
G4 G5
G4 G6
G5 G6
And I have 3 lists such as :
list1<-c("G1","G3")
list2<-c("G2")
list3<-c("G4","G5","G6")
and I would like to add a new column to the dataframe by adding the name of the list from which the GroupA and B come from such as
GroupsA GroupsB Lists
G1 G2 list1&list2
G1 G3 list1&list1
G1 G4 list1&list3
G1 G5 list1&list3
G1 G6 list1&list3
G2 G3 list2&list1
G2 G4 list2&list3
G2 G5 list2&list3
G2 G6 list2&list3
G3 G4 list1&list3
G3 G5 list1&list3
G3 G6 list1&list3
G4 G5 list3&list3
G4 G6 list3&list3
G5 G6 list3&list3
Here is the dput format of the df if it can helps :
structure(list(GroupsA = c("G1", "G1", "G1", "G1", "G1", "G2",
"G2", "G2", "G2", "G3", "G3", "G3", "G4", "G4", "G5"), GroupsB = c("G2",
"G3", "G4", "G5", "G6", "G3", "G4", "G5", "G6", "G4", "G5", "G6",
"G5", "G6", "G6")), class = "data.frame", row.names = c(NA, -15L
))