Message-ID: <6FF2D623-A9B6-4CFB-87B3-C3FC4A469BE2@comcast.net>
Date: 2012-02-09T18:03:42Z
From: David Winsemius
Subject: fill an array by rows
In-Reply-To: <4F340698.4010903@uea.ac.uk>
On Feb 9, 2012, at 12:47 PM, Jim Maas wrote:
> I've dug around but not been able to find anything, am probably
> missing something obvious.
>
> How can I fill a three-dimensional (or higher dimension) array by
> rows instead of columns.
>
> eg
>
> new1 <- array(c(1:125), c(5,5,5))
>
> works fine for me but fills it by columns and
>
> new2 <- array(c(1:125), c(5,5,5), byrow=TRUE)
>
> throws an error.
>
> Am I missing something obvious? I also tried transposing the 3-d
> array but that didn't work either.
You might want to look at aperm:
Perhaps:
new2 <- aperm(new1, c(2,1,3))
>
--
David Winsemius, MD
West Hartford, CT