Suppose I have a 4 dimensional n x n x n x n array A. A is a distance matrix, such that A[i,j,l,k] is the distance from location i,j to location pair l,k. Suppose I have an nxn
I guess you have changed the request from the one stated in the first paragraph. See if this answers the second version.
A [ cbind( which(T == 0, arr.ind=TRUE), which(T == 1, arr.ind=TRUE) )] #[1] 1 1
(At first I thought you might need abind but cbind works fine.)