[R] List to Array

Ben Bolker bolker at ufl.edu
Wed Apr 5 15:41:52 CEST 2006


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)))

  Ben Bolker




More information about the R-help mailing list