• Publicado: 18 Jun 2017

  • Archivado en: Economics, trade, Mexico, r-english

NAFTA trade dashboard

Tradewatch is a dashboard, written in R using the flexdashboard framework. Visualizations are made possible thanks to highcharter and other packages.

The main purpose of the dashboard is to monitor trade, mostly from the Mexican perspective, of goods and commodities with countries that are in NAFTA.

In the age of fake news and policy-by-twitter, hopefully this tool will help guide more informed debate (and decisions) with respect to trade between these three countries.

Notes and methodology

The dashboard consists of basically three sections:

The names of HS Codes have been abbreviated manually, they can be found here, however the code is still in between parenthesis. Should you want to look it up further, I recommend the UN Comtrade website


This release is a first and fast dive into the data, so I would be happy to listen to improvements to the tool, including some new indicators I haven’t added. FYI, I tried to build the export matrixes at a 4-level granularity, but highcharts couldn’t handle it, any suggestions on how to do it would be welcome.

You can contact me via twitter or at my blog’s issue page.


The newest I could build is from november 2016, which is the month all three countries have statistics ready.


The code used to build the dashboard consists of two files: a functions.R file that contains some functions for downloading and cleaning the data and a db.Rmd file that builds the dashboard using the knitr/flexdashboard process in RStudio.

Both of these files can be found here and here.

FYI, I borrowed heavily from here and here.