I have the following data.frame
:
df <- data.frame(V1 = c("A","X","A","Z","B","Y"),
V2 = c("B","Y","C","Y","C","W"),
stringsAsFactors=FALSE)
df
# V1 V2
# 1 A B
# 2 X Y
# 3 A C
# 4 Z Y
# 5 B C
# 6 Y W
I want to group all the values that occur together at some point and get the following:
list(c("A","B","C"), c("X","Y","Z","W"))
# [[1]]
# [1] "A" "B" "C"
#
# [[2]]
# [1] "X" "Y" "Z" "W"