View source: R/ots_create_tidy_data.R
ots_create_tidy_data | R Documentation |
Accesses api.tradestatistics.io
and
performs different API calls to transform and return tidy data.
ots_create_tidy_data(
years = 2019,
reporters = "all",
partners = "all",
commodities = "all",
sections = "all",
table = "yr",
max_attempts = 5,
use_cache = FALSE,
file = NULL
)
years |
Year contained within the years specified in
api.tradestatistics.io/year_range (e.g. |
reporters |
ISO code for reporter country (e.g. |
partners |
ISO code for partner country (e.g. |
commodities |
HS commodity codes (e.g. |
sections |
HS section codes (e.g. |
table |
Character string to select the table to obtain the data.
Default set to |
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 |
use_cache |
Logical to save and load from cache. If |
file |
Optional character with the full file path to save the data. Default set to |
A tibble that describes bilateral trade metrics (imports,
exports, trade balance and relevant metrics
such as exports growth w/r to last year) between a reporter
and partner
country.
## Not run:
# The next examples can take more than 5 seconds to compute,
# so these are just shown without evaluation according to CRAN rules
# Run `ots_countries` to display the full table of countries
# Run `ots_commodities` to display the full table of commodities
# What does Chile export to China? (2002)
ots_create_tidy_data(years = 2002, reporters = "chl", partners = "chn")
# What can we say about Horses export in Chile and the World? (2002)
ots_create_tidy_data(years = 2002, commodities = "010110", table = "yc")
ots_create_tidy_data(years = 2002, reporters = "chl", commodities = "010110", table = "yrc")
# What can we say about the different types of apples exported by Chile? (2002)
ots_create_tidy_data(years = 2002, reporters = "chl", commodities = "apple", table = "yrc")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.