Learn R Programming

comtradr (version 0.2.1)

ct_update_databases: Check for updates to country/commodity databases

Description

Use of the Comtrade API requires access to the Comtrade countries database and commodities database. The comtradr package keeps each DB saved as a data frame in the package directory, as Comtrade makes updates to these DB's infrequently (roughly once per year).

Usage

ct_update_databases(force = FALSE, verbose = TRUE,
  commodity_type = c("HS", "HS1992", "HS1996", "HS2002", "HS2007", "HS2012",
  "HS2017", "SITC", "SITCrev1", "SITCrev2", "SITCrev3", "SITCrev4", "BEC",
  "EB02"), commodity_url = NULL, reporter_url = NULL, partner_url = NULL)

Arguments

force

logical, if TRUE, both the country and commodity databases will be downloaded, regardless of the status of the DB's on file. Default value is FALSE.

verbose

logical, if TRUE, an update status message will be printed to console. Default value is TRUE.

commodity_type

Trade data classification scheme to use, see "details" for a list of the valid inputs. Default value is "HS", which is the default "type" of the commodity database on file upon install of comtradr. Please note that if the value passed to this arg doesn't match the values in variable "type" of the current commodity DB, then this function will replace the current commodity DB with that of the type specified by this arg. If you don't intend to change the type of the current commodity DB, then no input for this arg is required. To see the "type" of the current commodity DB, use ct_commodity_db_type.

commodity_url

Default value NULL, otherwise this should be the base url of the Comtrade json data directory. Only necessary if the Comtrade site changes from "https://comtrade.un.org/data/cache/". This partial url string will have a commodity extension appended to it to create a valid url. The commodity extension will be chosen based on the input to arg commodity_type.

reporter_url

Default value NULL, otherwise this should be a url as a char string that points to the reporter areas JSON dataset on the Comtrade website. Only necessary if the Comtrade site changes from https://comtrade.un.org/data/cache/reporterAreas.json

partner_url

Default value NULL, otherwise this should be a url as a char string that points to the reporter areas JSON dataset on the Comtrade website. Only necessary if the Comtrade site changes from https://comtrade.un.org/data/cache/partnerAreas.json

Value

Updated database of commodities and countries.

Details

This function will check to see if Comtrade has made any updates to either database. If an update is found, it will download the updated DB and save it to the comtradr package directory, and update the DB for use within the current R session.

The default for arg commodity_type is HS. Below is a list of all valid inputs with a very brief description for each, for more information on each of these types, see https://comtrade.un.org/data/doc/api/#DataAvailabilityRequests

  • HS: Harmonized System (HS), as reported

  • HS1992: HS 1992

  • HS1996: HS 1996

  • HS2002: HS 2002

  • HS2007: HS 2007

  • HS2012: HS 2012

  • HS2017: HS 2017

  • SITC: Standard International Trade Classification (SITC), as reported

  • SITCrev1: SITC Revision 1

  • SITCrev2: SITC Revision 2

  • SITCrev3: SITC Revision 3

  • SITCrev4: SITC Revision 4

  • BEC: Broad Economic Categories

  • EB02: Extended Balance of Payments Services Classification

Examples

Run this code
# NOT RUN {
ct_update_databases()
# }

Run the code above in your browser using DataLab