I have a seemingly simple calculation, where I have a data frame composed of 4 columns as shown below (Date, Origin, Destination, count). I would like to sum the count by Date, and unique pair of ID1 and ID2, meaning that A-B and B-A are ONE pair.
Date ID1 ID2 Count
12-1 A B 1
12-1 B A 1
12-1 D E 1
12-1 E D 2
12-1 Y Z 2
12-2 A B 1
12-2 B A 1
12-2 D E 1
12-2 E D 2
12-2 Y Z 2
From the date set we can either sum the "Count" column by unique combinations (e.g. A-B, B-A, D-E, E-D, etc.). However I would like to sum the count column by unique pair- meaning that A-B would also include B-A.
Ideally I would like to have the table summarized by Date and by unique pair.
I looked through everything, dyplyr functions such mutate, gather, unite- all to no avail.
Would be deeply grateful for any insight or pointing the right direction. Many thanks