Suppose I've got 5D array arr
.
To get 2d matrix with fixed 3rd, 4th and 5th indices I do something like: matr = arr[,,3,2,3]
. Suppose I've got list of indices idx = c(3,2,3)
. Is there any way to get same result using idx
? Something like matr = arr[,,idx]
? I've tried to do it like
idx = c(,, 3, 2, 3);
matr = arr[idx];
But it is obviously wrong.
UPD in a common case array may be more than 5 dimensional. So I need to do this for idx of any size.