aperm(a, perm=<<see below>>, reshape=T)
For arrays a dimnames attribute, if present, will be appropriately permuted, but names, if present, will be deleted.
# turns 50 x 4 x 3 into 50 x 3 x 4 myiris <- aperm(iris,c(1,3,2)) # make 150 x 4 matrix myiris <- matrix(aperm(iris,c(1,3,2)),150,4)# if bar is a matrix created from a file in the wrong order # (byrow was not set to TRUE), then the following sets it right t(aperm(t(bar),reshape=F))