get_comtrade: This function extracts data from the UN Comtrade database via...

Description Usage Arguments Value Author(s) Examples

Description

This function extracts data from the UN Comtrade database via their public API.

Usage

1
2
3
get_comtrade(url = "http://comtrade.un.org/api/get?", maxrec = 50000,
  type = "C", freq = "A", px = "HS", ps = "now", r, p = "all",
  rg = "all", cc = "TOTAL", fmt = "csv")

Arguments

maxrec:

Maximum no. of records returned (default = 50000): A valid integer in the range [1, 50000]. If the number of records returned by the query exceed max results are truncated to this number. In output types supporting metadata (e.g. json) information about the total number of records that would have been returned is included. type: Type of trade (default = C): Valid values: C Commodities (merchandise trade data), S (future) Services (trade in services data)

freq:

Frequency (default = A): A - Annual, M - Monthly

px:

Classification (default = HS): Trade data classification scheme. See list of valid classifications: HS (default) Harmonized System, H0 (HS 1992), H1 (HS 1996), H2 (HS 2002),H3 (HS 2007), H4 (HS2012), ST (SITC), S1 (SITC Revision 1),S2 (SITC Revision 2), S3 (SITC Revision 3), S4 (SITC Revision 4), BEC (Broad Economic Categories), for more see <URL: http://comtrade.un.org/data/doc/api/> and <URL: http://comtrade.un.org/db/mr/daReportersResults.aspx>

ps:

Time period (default = now): Depending on freq, time period can take either YYYY or YYYYMM or now or recent

r:

Reporting area: The area that reported the trade to UNSD,e.g. 0 (default), 842 (USA), see <URL: http://comtrade.un.org/data/cache/reporterAreas.json>

p:

Partner country (default = all): partner area. The area receiving the trade, based on the reporting areas data. See list of valid partners: <URL: http://comtrade.un.org/data/cache/partnerAreas.json>

rg:

Trade regime / trade flow (default = all): The most common area 1 (imports) and 2 (exports), see list of valid trade flows: <URL: http://comtrade.un.org/data/cache/tradeRegimes.json>

cc:

Classification code (default = AG2): a commodity code valid in the selected classification. Full lists of codes for eachcl assification are linked to above under the px parameter.Some codes are valid in all classifications: TOTAL Totaltrade between reporter and partner, no detail breakdown.;AG1, AG2, AG3, AG4, AG5, AG6 Detailed codes at a specific digit level. For instance AG6 in HS gives all of the 6-digit codes, which are the most detailed codes that are internationally comparable. Not all classifications have all digit levels available. See the classification specific codes for more information.; ALL All codes in the classification.

fmt:

Format (default = csv): Valid values are json or csv.

Value

Data set in the format specified (csv or json).

Author(s)

Li Guomin

Examples

1
2
3
4
s1 <- get_comtrade(r = "156", p = "124,484")
s2 <- get_comtrade(r = "156", ps="201201,201202,201203",p = "124,484")
ps5 = toString(2010:2014) #"2010, 2011, 2012, 2013, 2014"
s3 <- get_comtrade(r = "156", ps = ps5, p = "124")

Gabegit/gmdata documentation built on May 6, 2019, 5:32 p.m.