While preparing my slides for statistical graphics, a plot really caught my eye when I was playing around with the data. I started off by plotting the time seriesof GNI per capita by country, and as expected it got quite messy and incomprehensible.
## Download and manipulate the data<br>library(FAOSTAT)<br>raw.lst = getWDItoSYB(indicator = c("NY.GNP.PCAP.CD", "SP.POP.TOTL"))<br>raw.df = raw.lst[["entity"]]<br>traw.df = translateCountryCode(raw.df, from = "ISO2_WB_CODE", to = "UN_CODE")<br>mraw.df = merge(traw.df, FAOregionProfile[, c("UN_CODE", "UNSD_MACRO_REG")])<br>final.df = mraw.df[!is.na(mraw.df$UNSD_MACRO_REG), ]<br><br>## Simple ugly time series plot<br>ggplot(data = final.df, aes(x = Year, y = NY.GNP.PCAP.CD)) +<br> geom_line(aes(col = Country)) +<br> labs(x = NULL, y = "GNI per capita")<br>
So I decided to compute the ...
[Read more...]