Suppose I have a simple multidimensional structure, like this one:
somestr<-array(sample.int(2, 120, replace=TRUE), dim=c(4,5,6))
I\'m l
I think the which
function can do that:
which(somestr==2, arr.ind=TRUE)
(if I understood everything correctly)
R> set.seed(123)
R> somestr <- array(sample.int(2, 120, replace=TRUE), dim=c(4,5,6))
R> somestr
, , 1
[,1] [,2] [,3] [,4] [,5]
[1,] 1 2 2 2 1
[2,] 2 1 1 2 1
[3,] 1 2 2 1 1
[4,] 2 2 1 2 2
...
, , 6
[,1] [,2] [,3] [,4] [,5]
[1,] 2 1 1 1 2
[2,] 1 2 1 2 2
[3,] 1 2 2 2 2
[4,] 2 2 1 1 1
R> which(somestr==2, arr.ind=TRUE)
dim1 dim2 dim3
[1,] 2 1 1
[2,] 4 1 1
[3,] 1 2 1
[4,] 3 2 1
[5,] 4 2 1
...
[57,] 2 5 6
[58,] 3 5 6