Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201977

Filter rows based on a swapped combinations [duplicate]

$
0
0

This question already has an answer here:

Imagine I have a data frame with three columns were column 1 and 2 depicts unique combination with a certain output 'value'. However, I want to filter out those rows were the columns are actually just swapped, since the outcome is the same and retain one outcome of one set of combination.

e.g. 2 - 1 = 1 and 1 - 2 = 1 is technically the same

df <- data.frame(column1 = c(2,3,4,1,3,4,1,2,4), 
                 column2 = c(1,1,1,2,2,2,3,3,3), 
                 value = c(1,2,10,1,2,4,2,2,5))

Since I don't have any reasonable code which can tackle this issue, I appreciate any help and hint!!


Viewing all articles
Browse latest Browse all 201977

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>