Re: [R] "Inverting" a list

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Wed, 6 Feb 2008 18:00:40 -0500

This isn't a single command but its pretty short:

unstack(stack(L)[2:1])

On Feb 6, 2008 5:51 PM, hadley wickham <h.wickham_at_gmail.com> wrote:
> 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/
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 06 Feb 2008 - 23:04:22 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 07 Feb 2008 - 00:30:12 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive