I have data like this:
table <- data.frame(col1 = c("USA", "CHN", "DEU", "DEU"), col2 = c("DEU", "DEU", "USA", "CHN"), col3 = c(100, 150, 300, 250))
col1 col2 col3
1 USA DEU 100
2 CHN DEU 150
3 DEU USA 300
4 DEU CHN 250
How do I collapse this table based on the combination of values in col1 and col2 independent of the sequence of this combination -- so that I have the following table?
col1 col2 col3
1 USA DEU 400
2 CHN DEU 400
Many thanks for any advice you could provide
UPDATE: See updated data here:
AUS AUS 431.92164
AUS AUS 581.14942
AUS AUS 1822.10345
AUS AUS 1024.4436
AUS AUS 126.45221
AUS AUS 171.01716
AUS AUS 432.23415
AUS AUS 35.28675
AUS AUS 1488.02559
AUS AUS 0
AUS AUS 9057.73836
AUS AUS 9933.79762
AUS AUS 4307.49845
AUS AUS 73.33633
AUT AUT 1089.27094
AUT AUT 413.83978
AUT AUT 118.46822
AUT AUT 3700.34366