get_data: Downloads and processes the data from the API

Description Usage Arguments Value Examples

View source: R/get_data.R

Description

This function accesses atlas.media.mit.eduand perfoms different API calls to return tidy data. and data transforming.

Usage

1
2
get_data(origin = "all", destination = "all", years = 2000,
  classification = "sitc", max_attempts = 5)

Arguments

origin

ISO code for country of origin (e.g. chl for Chile). Default set to all. Run country_codes in case of doubt.

destination

ISO code for country of destination (e.g. chn for China). Default set to all. Run country_codes in case of doubt.

years

Numeric value greater or equal to 1962 and lower of equal to 2016. Default set to 2000.

classification

Any of the available trade classifications in the OEC (sitc, hs92, hs96, hs02 or hs07). Default set to sitc.

max_attempts

How many times to try to download data in case the API or the internet connection fails when obtaining data. Default set to 5.

Value

A tibble that describes bilateral trade metrics (imports, exports, trade balance and relevant metrics such as exports growth w/r to last year) between an origin and destination country.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Not run: 
# The next examples can take more than 5 seconds to compute, and specially for large 
economies so these are just shown without evaluation according to CRAN rules

# Run `country_codes` to display the full table of countries

# What does Chile export to China?
# year 2015 - SITC (4 characters)
get_data("chl", "chn", 2015)
# or with explicit parameter
get_data("chl", "chn", 2015, "sitc")

# What does Chile export to China?
# years 2010, 2011 and 2015 - HS07 (4 and 6 characters)
get_data("chl", "chn", c(2010, 2011, 2015), "hs07")

## End(Not run)

pachamaltese/OEC documentation built on May 24, 2019, 5:57 p.m.