Tuesday, March 25, 2014

Kazakh Arms Imports Visualized (Part 1)

I thought it would be fun to put together a graph that shows the arms suppliers for Kazakhstan in 2013 in a network form.  The data come from SIPRI and I put them into a simple association matrix.  I used the R Statnet package to make the data a network, and then just used plot features in R to make the graph look a little nicer. I think that this is a fun little visualization of where these arms are coming from.  Here's the graph:



The code to do this is pretty straightforward.  If you want the data in the text format, please email me.  The code is pasted below using "Pretty R."


library(statnet)
supplier <- read.table("supplier.txt")
kasnet2013.m <- as.matrix(supplier)
kaznet2013 <- as.network(kasnet2013.m,matrix.type="adjacency", directed = T)
 
vertsize <- supplier$Kazakhstan*.05+1
png("Kazakh_imports2013.png", height = 8, width=11, units="in", bg="transparent",
    res=600)
plot(kaznet2013, displaylabels=TRUE, displayisolates = FALSE,
     vertex.col=c("gray","gray","red","gray","gray", "red","sienna4"),
     vertex.cex = vertsize,
     main=list("Kazakstan Arms Suppliers 2013", col="sienna4"),
     sub=list("Size of Vertex represents Value of Arms from Country",
              cex= .9, col="sienna3"))
 
mtext("Data from SIPRI TIV Database", side = 2, cex=.75, col="dimgray")
dev.off()
Created by Pretty R at inside-R.org

No comments:

Post a Comment