I currently have a dataframe called countries with 2 columns "V1" and "V2." Both columns contain country abbreviations such US, CA, RU etc. Each row is a pair of countries so the first row can be US and RU. However, I want to extract unique pairs since some pairs are repeated such as (US,RU) and (RU,US). I want to extract the pair according to alphabetical order so (RU,US) would be extracted, not (US, RU).
Currently I have:
countries = filter(countries, countries$V1 < countries$V2)
However, this is causing an error.
Error in UseMethod("filter_") : no applicable method for 'filter_' applied to an object of class "c('matrix', 'array', 'character')"
I'm assuming there is an issue with how I am using the filter function to take out pairs according to alphabetical order. Is there a different way to do this?