ct_compare: Compare Countries

View source: R/analytics.R

ct_compareR Documentation

Compare Countries

Description

Compare multiple countries' trade in a given commodity, showing exports, imports, balance, and revealed comparative advantage.

Usage

ct_compare(reporters, commodity = "TOTAL", year = NULL, cache = TRUE)

Arguments

reporters

Character vector. ISO3 codes for countries to compare.

commodity

Character. Commodity code. Default "TOTAL".

year

Integer. Year to query.

cache

Logical. Default TRUE.

Value

A data.frame with columns: reporter, reporter_desc, exports, imports, balance, rca.

Examples


op <- options(comtrade.cache_dir = tempdir())

cmp <- tryCatch(ct_compare(c("GBR", "DEU", "FRA"), commodity = "87",
                           year = 2023),
                error = function(e) NULL)
if (!is.null(cmp)) head(cmp)

options(op)


comtrade documentation built on Dec. 3, 2026, 1:07 a.m.