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, ... )
Char vector of country names.
str, the country list to use for the search, valid inputs are "reporter" and "partner".
logical, to be passed along to arg ignore.case within
additional args to be passed along to
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 this great tutorial by Gloria Li and Jenny Bryan http://stat545.com/block022_regular-expression.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"