Visual representation of international commerce

Author: Xavier Fernández-i-Marín
January 28, 2013 - 2 minutes
Data visualization Software

I've done some work with data on International Commerce. Here I present a document with the connections between countries.

The plots

The document is a pdf file with four plots in each page, with a total of 344 pages. You can download it compressed as bzip (505 K) or zip (890 K).

Description of the plots

Each plot represents the percentage of imports (in red) and exports (in blue) that the first country has with the second, regarding all the imports and exports that the first country has.

Data source

Data is from the Direction of Trade Statistics of the IMF. Here I have selected Latin American and OECD countries.

A bit of programming

More details about the original data, the process and the details of the selection of countries can be found at the program that processes the information and stores it into a database. This script has been written in Perl.

The process of doing the plots can be seen in the folliwng code in R.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# We need a matrix of
# origin - destination - year - % of all imports - % of all exports
  
### First we get the total of the imports and exports of each country
commerce.imp <- data.frame(tmp.imp, prop.imp)
commerce.exp <- data.frame(tmp.exp, prop.exp)

# Then, merge the datasets
commerce <- merge(commerce.imp, commerce.exp,
                  by=c("orig", "year", "dest"), all.x=T, all.y=F)


# Now, select only desired columns
commerce.processed <- data.frame(commerce$orig, commerce$dest, commerce$year,
                                 commerce$prop.imp, commerce$prop.exp)
names(commerce.processed) <- c("orig", "dest", "year", "prop.imp", "prop.exp")


n.countries <- 48
v.countries <- 1:n.countries
years <- 1948:2004


pdf(height=8.263889, width=11.68056)
par(mfrow=c(3,2))
for (o in 1:n.countries) {
  for (d in 1:n.countries) {
    if (o != d) {
      vals.imp <- prop.imp[orig==o & dest==d]
      vals.exp <- prop.exp[orig==o & dest==d]
      name.orig <- countries$nom_pais[countries$id_pais == o]
      name.dest <- countries$nom_pais[countries$id_pais == d]
      years.sel <- years
      if (length(vals.imp) == length(years.sel))
        {
          plot(years.sel, vals.imp, type="lines", col="red", lwd=1.5, ylim=c(0,1),
               main=paste(name.orig, " - ", name.dest, sep=""),
               xlab="", ylab="")
          lines(years, vals.exp, col="blue", lwd=1.5)
        }
    }
  }
}
dev.off()

V-Dem by default: Load and process V-Dem democracy scores in R

Author: Xavier Fernández-i-Marín
January 11, 2019 - 6 minutes
Tutorial of how to perform data analysis of the Varieties of Democracies (V-Dem) dataset in R
Governance R Data visualization

Agency proliferation: processing the dataset of institutional characteristics of regulatory agencies - RegGov 2018

Author: Xavier Fernández-i-Marín
December 17, 2018 - 10 minutes
Regulatory agencies Governance Data visualization

Bavarian state elections 2018 - Evaluation of the forecasts

Author: Xavier Fernández-i-Marín
October 16, 2018 - 3 minutes
Comparison of the electoral results and forecasts for Bavarian elections 2018
Electoral forecast Bayesian Data visualization
comments powered by Disqus