Downloads and processes the data from the API
getdata(origin, dest, year, classification)
Country code of origin (e.g. "chl" for Chile)
Country code of destination (e.g. "chn" for China)
The OEC's API ranges from 1962 to 2016
Trade classification that can be "1" (HS92 4 characters since year 1995), "2" (SITC rev.2 4 characters since year 1962) or "3" (HS92 6 characters since year 1995)
# NOT RUN {
# Run countries_list() to display the full list of countries
# For the example Chile is "chl" and China is "chn"
# Download trade between Chile and China
# Year 2016 (HS92 4 characters)
# getdata("chl", "chn", 2016)
# getdata("chl", "chn", 2016, 1) # equivalent to last command
# Download trade between Chile and China
# Year 2016 (SITC rev2 4 characters)
# getdata("chl", "chn", 2016, 2)
# Download trade between Chile and China
# Year 2016 (HS92 6 characters)
# getdata("chl", "chn", 2016, 3)
# }
Run the code above in your browser using DataLab