# [R] multidimensional lists

From: Evan Cooch <cooch17_at_verizon.net>
Date: Wed 27 Sep 2006 - 16:07:48 GMT

So far, in R, I've used lists. Given (say) 4 matrices (A,B,C,D), in MATLAB I can use

test={A,B,C,D} for a row vector cell array, or

test={A;B;C;D} for a column vector cell array.

In R, I get more or less the same thing using

test=list(A,B,C,D)

but this only gives me a row list. For a bunch of technical reasons, I need to be able to control the orientation (as noted)- this is especially true for n-dimensional cell arrays. In MATLAB, for example, I could generate a (say) 2x2 cell array using

test={A B;C D}

test=list(A,B,C,D);
dim(test) < c(2,2);

This seems to work, but defaults to bycolumn (in other words, instead of

A B
C D

I get

A C
B D

)

test=t(test) as needed to flip the thing around to byrow.

OK, so the question is - is there a better way? This *seems* to work, but I'm discovering that R is a lot like working with LaTeX (something I know much more about) - you can do most things, but there is often a more elegant way if you can figure out how to find out about it.