I have a matrix with binary data representing whether each column field is relevant to each row element. I'm looking to create a two column dataframe identifying the name of each field associated with each row. How can I do this in R?
Here is an example of what I'm starting with:
A B C
W 1 1 0
X 0 1 1
Y 1 1 1
Z 0 1 1
And I'm looking to end up with this:
Element | Relevant Field
W|A
W|B
X|B
X|C
Y|A
Y|B
Y|C
Z|B
Z|C
Any hints? Thanks!