[R] How to invert a list ?

Carlos Petti carlos.petti at gmail.com
Tue Aug 10 18:58:09 CEST 2010


Dear list,

I have a list, as follows :

a <- 5
names(a) <- "a"
b <- 9
names(b) <- "b"
c <- 15
names(c) <- "c"
x <- list("i" = a, "j" = b, "j" = c)

I want to invert the list, like this :

$a
i
5

$b
j  k
9 15

I do not find a clean solution.

Could anyone give me elegant ideas ?

Thanks in advance,
Carlos



More information about the R-help mailing list