[R] lists to arrays

Jason Turner jasont at indigoindustrial.co.nz
Wed Jan 22 07:35:04 CET 2003


On Tue, Jan 21, 2003 at 05:33:57PM -0700, Katalin Csillery wrote:
> Does anyone know how to coerce a list to an array? I have a list with
> equal sized matrixes and I want to coerce it to a 3D array.

lists are special.  you'll have to unlist() first.  As an example:

zz <- list(a=matrix(1:9,ncol=3),b=matrix(10:18,ncol=3))
aa <- array(unlist(zz),dim=c(3,3,2))

However, useful as arrays are, finding a way to do the same job with
arrays can be very helpful - they're quite flexible.

Cheers

Jason


-- 
Indigo Industrial Controls Ltd.
64-21-343-545
jasont at indigoindustrial.co.nz




More information about the R-help mailing list