getComtrade: Download data from Comtrade

Description Usage Arguments Details Value See Also Examples

View source: R/getComtrade.R

Description

Download trade data from the Comtrade API, provided by the United Nations.

Usage

1
2
3
getComtrade(region, partner, time = "now", freq = "A", type = "C",
  classification = "HS", tradeflow = "all", cc = "TOTAL", fmt = "json",
  maxrec = 100000)

Arguments

region

the reporting region/country

partner

the partner region

time

the time period as a string. Can be a year, i.e. "2013" or a month in a year, i.e. "201301", depending on whether freq is "A" or "M"

freq

frequency, can be either "A" for annual data or "M" for monthly data

type

type of trade flow. Currently only "C" for commodity. In the future maybe also "S" for Services.

classification

revision of the HS classification that is used. Default is "HS" which corresponds to "HS, as reported", but can also be "H0", "H1", ..., "ST" (SITC classification, as reported), "S1", ... or "BEC" (Broad Economic Categories). The homepage has more information on this.

tradeflow

the tradeflow, can be "1" for imports, "2" for exports or "all" for both (default)

cc

the classification code for the commodity, such as "0101" for live animals, according to the HS classification. Special codes are "TOTAL" for the total trade between reporter and partner, "ALL" for all commodities or "AG1" to "AG6" for detailed codes at specific level.

fmt

the format, either "csv" for a .CSV download or "json" for a JSON download. JSON also provides a validation list, which contains any errors and query information.

maxrec

the maximum number of records, default = 100000.

Details

Downloads the data and returns it in usable format, see See also for the API-homepage

Value

a list with a validation list (if fmt = "JSON" was specified) and a data.frame which contains the data

See Also

http://comtrade.un.org/data/doc/api/

Examples

1
dta <- getComtrade(region = "40", partner = "688")

zauster/RComtrade documentation built on May 4, 2019, 9:12 p.m.