[R] list to matrix?

R. Michael Weylandt michael.weylandt at gmail.com
Tue Dec 4 23:58:42 CET 2012


On Tue, Dec 4, 2012 at 8:17 PM, arun <smartpink111 at yahoo.com> wrote:
> Hi,
> Try this:
> list1<-list(c(50000, 101), c(1e+05, 46), c(150000, 31), c(2e+05, 17),
>     c(250000, 19), c(3e+05, 11), c(350000, 12), c(4e+05, 25),
>     c(450000, 19), c(5e+05, 16))
>
>
> res<-t(sapply(list1,function(x) x))

Bah Humbug! (In Christmas cheer)

No need for all this (see solutions including mine already given) --
but even without those, this is silly. An identity map is a real waste
if you just want the simplification bit of sapply() -- you'd be much
better just using simplify2array()

Michael




More information about the R-help mailing list