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 = 2020,
importers = "all",
exporters = "all",
sectors = "all",
industries = "all",
table = "itpde_imp",
max_attempts = 5,
use_cache = FALSE,
file = NULL
)
years |
Year contained within the years specified in
api.tradestatistics.io/year_range (e.g., |
importers |
Importers (e.g. |
exporters |
Exporters (e.g. |
sectors |
Sectors (e.g. |
industries |
Industries (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_sectors` to display the full table of sectors
# Agricultural trade (sector)
ots_create_tidy_data(years = 2020, sectors = "Agriculture",
table = "itpde_sec")
# Cereal products trade (industry-importer)
ots_create_tidy_data(years = 2020, importers = "chl",
industries = "Cereal products", table = "itpde_imp_ind")
# Aggregate trade (bilateral)
ots_create_tidy_data(years = 2020, importers = "chl",
exporters = c("arg", "bra"), table = "itpde_imp_exp")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.