ct_country_lookup: UN Comtrade country database query

Description Usage Arguments Details Value See Also Examples

Description

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/

Usage

1
2
ct_country_lookup(search_terms, type = c("reporter", "partner"),
  ignore.case = TRUE, ...)

Arguments

search_terms

Char vector of country names.

type

str, the country list to use for the search, valid inputs are "reporter" and "partner".

ignore.case

logical, to be passed along to arg ignore.case within grepl. Default value is TRUE.

...

additional args to be passed along to grepl.

Details

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

Value

A character vector of country names that are complete or partial matches with any of the input country names.

See Also

grepl

Examples

1
2
# Look up all reporters that contain the terms "korea" and "vietnam"
ct_country_lookup(c("korea", "vietnam"), "reporter")

ropensci/comtradr documentation built on June 12, 2019, 7:35 a.m.