I have the following table:
df <- read.table(textConnection("V1 V2 V3
1 T Y
4 Y T
1 O P
2 Q E
2 E Q
5 C V
2 V C"), header=TRUE)
I want to aggregate based on bidirectional hits on V2 and V3 as a sum of of V1.
so the result will be
V1 V2 V3
5 Y T ### the order here does not matter (Y T or T Y are the same)
1 O P
4 Q E
7 V C
I mean can always go for traditional for loop to do this, but i think there should be a better way of doing this in R?