load_rts: A function for loading RTS data via HMRC's API.

View source: R/load_rts.R

load_rtsR Documentation

A function for loading RTS data via HMRC's API.

Description

A function for loading RTS data via HMRC's API.

Usage

load_rts(
  month = NULL,
  flow = NULL,
  sitc = NULL,
  country = NULL,
  region = NULL,
  uk_country = NULL,
  join_lookup = TRUE,
  print_url = FALSE,
  output = "tibble",
  skip_interval = NULL,
  use_proxy = FALSE,
  ...
)

Arguments

month

The month(s) to be loaded in the form of a vector of two integers (YYYYMM), where the first element is the minimum date, and second the maximum date. Defaults to NULL (all months).

flow

The trade flow to be loaded. Takes one ore more integers (1, 2, 3, and/or 4), where 1 is EU imports, 2 is EU exports, 3 is non-EU imports, and 4 is non-EU exports. Defaults to NULL (all flows).

sitc

The range of SITC2 commodity codes to be loaded (min and max), in the form of a numeric vector. Defaults to NULL (all commodities).

country

One or more destination or origin countries by their 2-letter ISO code. Defaults to NULL (all countries).

region

One or more destination or origin regions. Defaults to NULL (all regions). Takes one or more of the following broad categories: "Asia and Oceania", "Eastern Europe exc EU", "European Union", "Latin America and Caribbean", "Middle East and N Africa", "North America", "Sub-Saharan Africa", "Western Europe exc EU", "Western Europe exc EC", "Low Value Trade", "Stores and Provisions", and/or "Confidential Region".

uk_country

One or more destination or origin UK countries. Defaults to NULL (all countries). Takes one or more of the following: "England", "Wales", "Scotland", "Northern Ireland", and/or "Unallocated". England may have multiple regions within it, and Unallocated may be split between known and unknown.

join_lookup

A logical value indicating whether results should be joined with lookups from the API. Defaults to TRUE. Setting to FALSE will return a smaller but less human-readable dataframe containing only codes.

print_url

A logical. Defaults to FALSE. Setting this to TRUE will print the URL(s) used to load the trade data to the console.

output

A character specifying if a tibble ("tibble") or dataframe ("df") should be returned. Defaults to "tibble".

skip_interval

Passed to load_custom(). Indicates the skip interval for paginated results. Defaults to NULL; this uses the skip parameter automatically generated by the API. Setting this to a different non-negative integer value is currently not supported.

use_proxy

A logical. Defaults to FALSE. Setting this to TRUE will allow the use of a proxy connection using 'use_proxy()' from 'httr'.

...

Optional arguments to be passed along to 'use_proxy()' when using a proxy connection (by setting use_proxy to TRUE). See the 'httr' documentation for more details.

Value

Returns a dataframe or tibble

Examples

## Not run: 
# Obtaining all trade from SITC2 code 00 - Live animals to
# 11 - Beverages in 2019 via the RTS endpoint:

load_rts(month = c(201901, 201912), sitc = c(00, 11))


## End(Not run)

pvdmeulen/uktrade documentation built on Feb. 18, 2025, 7:54 p.m.