I have a dataframe that looks like this
> df
Col1 Col2 P_value
Cell1 Cell2 0.001
Cell2 Cell1 0.05
Cell4 Cell1 0.01
Cell5 Cell2 0.03
Cell2 Cell3 0.008
Cell1 Cell4 0.008
I want to subset to a new dataframe, in which only strings present in BOTH Col1 and Col2 in both orders. So here, Cell1 and Cell2, when matched, appear in both Col1 and Col2.
> df
Col1 Col2 P_value
Cell1 Cell2 0.001
Cell2 Cell1 0.05
Cell1 Cell4 0.008
Cell4 Cell1 0.01
So here, Cell1 and Cell2, when matched, appear in both Col1 and Col2. Same for Cell1 and Cell4. This never happens for other strings.