suppose we have a matrix , and we want to extract zero value from the matrix the code will be some thing like:
A <- matrix( c(4, 0, 3, 1, 2, 0,5,6,8,9,3,2,3,4,5,6,7,8,9,0,12,34,3,4,5,0,4, 3, 1, 25, 4,0,6,0,4,12,2,3,4,5,6,7,12,7,0), nrow=5,ncol=9,byrow = TRUE)
w<- which(A == 0 , arr.ind = TRUE)
the indices of zero value are :
> w
row col
[1,] 1 2
[2,] 3 2
[3,] 4 5
[4,] 1 6
[5,] 4 7
[6,] 3 8
[7,] 5 9
my question is :how to group the result of indices into two subsets like
1 2 3 6 8
4 5 7 9
What about if the condition ( extract all the values >= 9) the result should be two groups
1 2 3 4 9
5 7