[R] List to Array

Gabor Grothendieck ggrothendieck at gmail.com
Wed Apr 5 15:50:21 CEST 2006


On 4/5/06, Ben Bolker <bolker at ufl.edu> wrote:
> Werner Wernersen <pensterfuzzer <at> yahoo.de> writes:
>
> >
> > Hi,
> >
> > this is probably the easiest thing to do but I manage
> > not finding the answer:
> > I have a list with matrices of exact same format and
> > headers. Now I would like to transform the list into
> > an normal array. What is the proper way to do this?
>
>  I think if you really mean array (i.e. an n-dimensional
> table with n>2) then something like the following will do it:
>
> ## create an example list of matrices
> z <- replicate(5,matrix(runif(9),nrow=3),simplify=FALSE)
> library(abind)
> do.call("abind",c(z,list(along=3)))

Note that if that is what he is looking for then

abind(z, along = 3)

will do it too.




More information about the R-help mailing list