[R] "Inverting" a list

hadley wickham h.wickham at gmail.com
Wed Feb 6 23:51:05 CET 2008


Is there a built in function to invert a list?  i.e. to go from

list(
  a = c("1", "2", "3"),
  b = c("1"),
  d = c("2", "4")
)

to

list(
 "1" = c("a", "b"),
 "2" = c("a", "d"),
 "3" = "a",
 "4" = "2"
)

Hadley

-- 
http://had.co.nz/



More information about the R-help mailing list