Invert a List of Character Vectors in R

Viewed 1797

What is an efficient way from inverting a list of character vectors as shown below?

Input

lov <- list(v1=c("a", "b"), v2=c("a", "c"), v3=c("a"))

Expected

list(a=c("v1", "v2", "v3"), b=c("v1"), c=c("v2"))

Similar to Revert list structure, but involving vectors:

1 Answers
Related