Skip to content

amannj/comtradeRggregator

Repository files navigation

comtradeRggregator

Status_Badge codecov R-CMD-check

The “comtradeRggregator” package provides a simple tool to download and reclassify large chunks of Comtrade trade data.

The package offers functionality to download and aggregate Comtrade trade data using Comtrade’s API by building on the comtradr package. Furthermore, it provides tools for easy reclassification of trade data using official concordance tables from the United Nations Statistical Division (UNSD) and the World Integrated Trade Solution (WITS).


Why this package?

At a glance

comtradeRggregator brings together a set of convenient features for Comtrade trade data download and reclassification that are absent from either the Comtrade or WITS web interfaces:

Feature Comtrade WITS comtradeRggregator
Incorporating recent data updates and revisions yes with delay yes (via Comtrade)
Extraction of monthly trade data yes no yes
User limits without registration yes yes no
API integration in R comtradr no comtradr
Designated option to download mirror trade data no no yes
Reclassification of trade data according to official standards no WITS WITS and UNSD

Package features in detail

  • Downloads and aggregates Comtrade data using Comtrade’s API building on the comtradr package by offering more functionality for bulk and mirror data downloads.

  • Supports extraction of trade data for individual countries (‘from country A to country B’) as well as bulk downloads of multiple countries (‘from group of countries C to group of countries D’) as well as aggregated global trade data (‘from country (a group of countries) E to the World’).

  • Supports many key features of comtradr such as the option to download trade data following different trade classifications offered by Comtrade; see Comtrade API Data Availability Request for more information. The full list of possible trade classifications and their corresponding input arguments used in the comtradeRggregator package is provided in the Trade Classifications table:

Trade Classifications

Description Trade code; use either version as input for argument Level of (dis-)aggregation for input argument ag
HS combined, as reported HS TOTAL,AG2, AG4, AG6
HS 1988/1992 HS1992, H0 TOTAL,AG2, AG4, AG6
HS 1996 HS1996, H1 TOTAL,AG2, AG4, AG6
HS 2002 HS2002, H2 TOTAL,AG2, AG4, AG6
HS 2007 HS2007, H3 TOTAL,AG2, AG4, AG6
HS 2012 HS2012, H4 TOTAL,AG2, AG4, AG6
HS 2017 HS2017, H5 TOTAL,AG2, AG4, AG6
SITC Standard International Trade Classification, as reported SITC, ST TOTAL,AG1, AG2, AG3, AG4, AG5
SITC Revision 1 SITCrev1, S1 TOTAL,AG1, AG2, AG3, AG4, AG5
SITC Revision 2 SITCrev2, S2 TOTAL,AG1, AG2, AG3, AG4, AG5
SITC Revision 3 SITCrev3, S3 TOTAL,AG1, AG2, AG3, AG4, AG5
SITC Revision 4 SITCrev4, S4 TOTAL,AG1, AG2, AG3, AG4, AG5
Broad Economic Categories Rev. 4 BEC, BEC4 TOTAL,AG1, AG2, AG3
Extended Balance of Payments Services Classification EB02 TOTAL, ALL
  • Supports extraction of annual as well as monthly Comtrade trade data.

  • Provides function for easy reclassification of trade data using official concordance tables from the [United Nations Statistical Division (UNSD) - see here and here, and the World Integrated Trade Solution (WITS). For a complete summary of available Concordance Tables, please see below. To access any of the respective concordance tables in R, type <tradecode from>_<tradecode to>. For example, the concordance table for reclassifying H3 trade data according to the H0 nomenclature is stored as object H3_H0, and its R help file can be accessed by typing ?H3_H0. The R help files provide further information on the nature and individual features of the respective concordance matrices.

Concordance Table

From…

…to

BEC

Harmonised System

ISIC

SITC

BEC4 BEC5 CCCN CPC GTAP H0 H1 H2 H3 H4 I2 I3 I31 I4 MTN SIC S1 S2 S3 S4
Harmonised System (HS)
HS W . W W W W W W W W W W . . W W W W W W
H0 W . W W W . . . . . W W . . W W W W W W
H1 W . W W W W/U . . . . W W . . W W W/U W/U W/U W
H2 W . W W W W/U W/U . . . W W . . W W W/U W/U W/U W
H3 W . W W W W/U W/U W/U . . W W . . W W W/U W/U W/U W/U
H4 U U . U U U U U U . . . U U . . U U U U
H5 U . . . . U U U U U . xa . . . . U U U U
Standard International Trade Classification (SITC)†
S1 W . . . . . . . . . . . . . . . . . . .
S2 W/U . . . . . . . . . W . . . . . U . . .
S3 . . . . . . . . . . . . . . . . U U . .
S4 . . . . . . . . . . . . . . . . . . . .
International Standard Industrial Classification (ISIC)††
I2 . . . . . . . . . . . U U . . . . . . .
I3 . . . . . . . . . . U . U . . . . . . .
I3.1 . . . . . . . . . . . U . U . . . . . .
Note: W for WITS; U for UNSD.
†: For the Standard International Trade Classification (SITC) standard, AG4 as well as AG5 data is required.
††: ISIC nomenclature not available as Comtrade download option; concordance tables provided to facilitate re-classification across different standards.
x a : Example for concordance across seemingly unrelated classifications: H5 >> H3 >> I3.
  • Supports extraction of mirrored Comtrade trade data. This is useful as sometimes trade data between countries does not add up. For example, say, in 2020 country A reported USD X millions exports to country B while B was reporting USD Y millions, where X ≠ Y.


Further notes

Using up-to-date trade information

Data availability varies by country and classification, and new trade data is released/revised very frequently on Comtrade. comtradeRggregator uses trade information corresponding to official Comtrade data availability which it updates once a day and stores locally on your machine:

<your local package location>/data/Comtrade_DataAvailability-<date stamp>.rds

The locally stored Comtrade Data Availability file is used in every download_Comtrade() data query. In other words, if new data becomes available and is documented in the official Comtrade data availability file, comtradeRggregator will use this information no later than 24 hours after its publication. The Comtrade Data Availability file can be accessed in R by typing Comtrade_DA, and the corresponding help page can be accessed by typing ?Comtrade_DA.

Extraction of monthly trade data

Monthly trade data is only reported as HS Combined (HS) which combines all revisions of the Harmonised System nomenclature. As a country reports its tariff scheduled for a given year in only one revision, that is HS1992 (H0), HS1996 (H1) or HS2002 (H2) etc., combining these different revisions enables users to choose products without having to know in which nomenclature a particular country reports in a particular year; see here for more information on the HS Combined nomenclature.

Reclassification of trade data to other standards

Reclassification of Comtrade trade data is possible using the information in the Concordance Table by employing the function convert_Comtrade(). The function requires trade data at the most granular levels for the Harmonised System (HS) nomenclature, i.e., AG6. For the Standard International Trade Classification (SITC) standard, AG4 as well as AG5 data is required.


Installation

To install the latest development version of comtradeRggregator directly from GitHub, use:

# Download `comtradeRggregator`; private repository, requires `auth_token`.
devtools::install_github("amannj/comtradeRggregator",
  ref = "master",
  auth_token = auth_token,
  force = TRUE
)

For more information as well as practical examples, please see the Get Started section of the package web page.


Credits and related projects

About

Download and Reclassify Large Chunks of Comtrade Trade Data

Topics

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages