0

I have a list:

ll <- list(A=c("p1","p2"),B=c("p1","p4"),C=c("p3","p6"))

And I'm looking for a function that will convert it into a data.frame such that one column (a below) holds the unique elements of the unlisted ll, and the other (b below) holds the names of list elements to which the unlisted elements correspond to in ll.

The resulting data.frame for this example would therefore be:

data.frame(a = c("p1","p1","p2","p3","p4","p6"),
           b = c("A","B","A","C","B","C"))
dan
  • 6,048
  • 10
  • 57
  • 125

0 Answers0