Home / Open Resources
Open Resources
Code, data, programming packages and dashboards that offer readers a range of market intelligence.
-
01
comexTL: a Brazilian foreign trade data package in R
The comexTL package represents a complete and modern solution for accessing and analyzing Brazilian foreign trade data directly in the R environment. Developed to overcome the traditional limitations of accessing official ComexStat (MDIC) data, the package offers a unified interface that eliminates the need for manual downloads, complex file processing and detailed knowledge of classification code structures.
The package implements four specialized modules: (1) intelligent management of reference tables with a caching system, including NCM codes, countries, states (UFs) and municipalities; (2) detailed analysis of exports by NCM with flexible aggregations; (3) specialized analysis of imports with specific metrics (FOB, freight, insurance) and automatic calculation of CIF values; and (4) analysis of municipal foreign trade based on data by HS4 and the company's municipality.
The comexTL architecture uses Apache Arrow technology for efficient processing of large Parquet files, hosted on Cloudflare R2 infrastructure, ensuring high performance and availability. The multilayer caching system optimizes repeated queries and allows offline work, while automatic validation and error-handling functions ensure robustness in data analysis.
Features include hierarchical filtering by HS codes (HS2, HS4, HS6), multiyear time analysis, aggregation by geographic variables (country, state, municipality), logistics variables (mode of transport, URF) and economic variables (FOB value, weight, quantity). The package automatically calculates relevant derived metrics, such as the percentage share of freight and insurance in imports, counts of unique municipalities in regional analyses and sectoral classifications based on HS codes.
This work fully documents the use of the package, presenting everything from fundamental concepts to advanced analyses, including practical examples of monitoring dashboards, comparative regional analyses and integration with other tools in the R ecosystem. The documentation aims to serve both beginners and experienced researchers in foreign trade analysis, offering a solid foundation for academic studies and professional applications in the sector.
- R
- ComexStat
- Apache Arrow
- Parquet
-
02
Data
Databases systematized by Theta Economics, open for download, each accompanied by a data brief: WTO decisions, trade defense, MAPA non-tariff measures and the Rural Insurance Premium Subsidy Program (PSR).
- WTO
- Trade defense
- MAPA
- PSR
-
03
Agro Leal
Theta Economics arm dedicated to the interface between agribusiness, international trade and environmental regulation.
- Agribusiness
- International trade
- Environmental regulation
-
04
COMEX Reports
Foreign trade dashboard with reports built from official data: the Brazilian trade balance over the last ten years, exports of agricultural commodities and dependence on imported fertilizers, energy trade and the most atypical movements of the last month relative to the historical average.
- Trade balance
- Commodities
- Energy
