UN Comtrade country database querySource:
Country names passed to the Comtrade API must have precise spelling/capitalization. This is a helper function for querying the country names/spelling used by Comtrade.. It takes as input a vector of country names, output is any country names that contain any of the input strings, using regex via the base function grepl. For use with the UN Comtrade API, full API docs can be found at https://comtrade.un.org/data/doc/api/
ct_country_lookup( search_terms, type = c("reporter", "partner"), ignore.case = TRUE, ... )
A character vector of country names that are complete or partial matches with any of the input country names.
This function uses regular expressions (regex) to find matches within the country DB. This means it will treat as a match any country string that contains the input search term. For more on using regex within R, see https://stat.ethz.ch/R-manual/R-devel/library/base/html/regex.html
# Look up all reporters that contain the terms "korea" and "vietnam" ct_country_lookup(c("korea", "vietnam"), "reporter") #>  "Dem. People's Rep. of Korea" "Fmr Dem. Rep. of Vietnam" #>  "Fmr Rep. of Vietnam" "Rep. of Korea"