Learn R Programming

oec (version 1.0.3)

getdata: Downloads and processes the data from the API

Description

Downloads and processes the data from the API

Usage

getdata(ORIGIN, DESTINATION, CLASSIFICATION, YEAR)

Arguments

ORIGIN
is the country code of origin (e.g. "chl" for Chile)
DESTINATION
is the country code of origin (e.g. "chn" for China)
CLASSIFICATION
refers to the trade classification that can be "6" (HS92 6 characters) or "8" (HS92 8 characters) for the year 1995 and going or "4" (SITC rev.2 4 characters) for the year 1962 and ongoing
YEAR
is the year and the OEC's API ranges from 1962 to 2014

Value

Downloads the data from the OEC's API and creates the data files in json and csv formats that are needed to create the visualizations.

Examples

Run this code
# Run countries_list() to display the full list of countries
# Chile is "chl" and China is "chn"

# Download Chile (chl) and China (chn) trade data (imports, export and trade balance)
getdata("chl", "chn", 6, 2010)

# Download trade data from OEC's API (HS92 6 characters product lists)
getdata("chl", "chn", 6, 2010)

# Download trade data from OEC's API (SITC rev.2 4 characters product lists)
getdata("chl", "chn", 4, 2010)

Run the code above in your browser using DataLab