I have this matrix and i want to get a 2 column matrix, where one column has the rowname and the other column, the colname of cells with value 1
x
X1 X2 X3
X1 1 0 1
X2 0 1 0
X3 0 1 1
X4 1 0 0
str(x)
num [1:886, 1:886] 1 0 1 1 1 0 1 1 1 1
I want a matrix like this
# X1 X1
# X1 X3
# X2 X2
# X3 X2
# X3 X3
# X4 X1
which are the pairs that have value=1
Thanks in advance, A.
Here's one line answer
You can do something like this :
Which will give :
here another option :
And to get the OP display , we order by the first column:
Here I mat is your imput , that I reproduce :