Reputation: 894
Let A[ , , ] be an array of dimension [2,3,4]
A[ , , ]
array
[2,3,4]
For example,
A <- array(1:24,c(2,3,4))
I want to get a new array B of dimension [2,4,3] such that
B
[2,4,3]
B[i,j,k]=A[i,k,j]
for all i,j,k.
i,j,k
Upvotes: 2
Views: 54
Reputation: 269526
Use aperm:
aperm
aperm(A, c(1, 3, 2))
Upvotes: 3