Use aperm on the output of array:
> aperm(array(1:8, dim=c(2,2,2)), perm=c(2,1,3))
, , 1
[,1] [,2]
[1,] 1 2
[2,] 3 4
, , 2
[,1] [,2]
[1,] 5 6
[2,] 7 8
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at
r-project.org] On Behalf Of Jim Maas
> Sent: Thursday, February 09, 2012 9:47 AM
> To: r-help at r-project.org
> Subject: [R] fill an array by rows
>
> 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.
>
> TIA
>
> Jim
>
> --
> Dr. Jim Maas
> University of East Anglia
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.